Skip to content

Commit 0b044f7

Browse files
authored
When attaching JSDoc diagnostics, make sure to only include diagnostics that actually belong with the JSDoc (microsoft#57271)
1 parent a641405 commit 0b044f7

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

src/compiler/parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8760,7 +8760,7 @@ namespace Parser {
87608760
if (!jsDocDiagnostics) {
87618761
jsDocDiagnostics = [];
87628762
}
8763-
jsDocDiagnostics.push(...parseDiagnostics);
8763+
addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
87648764
}
87658765
currentToken = saveToken;
87668766
parseDiagnostics.length = saveParseDiagnosticsLength;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [tests/cases/conformance/jsdoc/errorIsolation.ts] ////
2+
3+
=== errorIsolation.js ===
4+
const async = { doSomething: _ => {} };
5+
>async : Symbol(async, Decl(errorIsolation.js, 0, 5))
6+
>doSomething : Symbol(doSomething, Decl(errorIsolation.js, 0, 15))
7+
>_ : Symbol(_, Decl(errorIsolation.js, 0, 28))
8+
9+
async.doSomething(
10+
>async.doSomething : Symbol(doSomething, Decl(errorIsolation.js, 0, 15))
11+
>async : Symbol(async, Decl(errorIsolation.js, 0, 5))
12+
>doSomething : Symbol(doSomething, Decl(errorIsolation.js, 0, 15))
13+
14+
/***/
15+
() => {}
16+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/conformance/jsdoc/errorIsolation.ts] ////
2+
3+
=== errorIsolation.js ===
4+
const async = { doSomething: _ => {} };
5+
>async : { doSomething: (_: any) => void; }
6+
>{ doSomething: _ => {} } : { doSomething: (_: any) => void; }
7+
>doSomething : (_: any) => void
8+
>_ => {} : (_: any) => void
9+
>_ : any
10+
11+
async.doSomething(
12+
>async.doSomething( /***/ () => {}) : void
13+
>async.doSomething : (_: any) => void
14+
>async : { doSomething: (_: any) => void; }
15+
>doSomething : (_: any) => void
16+
17+
/***/
18+
() => {}
19+
>() => {} : () => void
20+
21+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @noEmit: true
2+
// @checkJs: true
3+
// @filename: errorIsolation.js
4+
const async = { doSomething: _ => {} };
5+
async.doSomething(
6+
/***/
7+
() => {}
8+
);

0 commit comments

Comments
 (0)