When attaching JSDoc diagnostics, make sure to only include diagnostics that actually belong with the JSDoc (#57271)

This commit is contained in:
Abraham Guo
2024-02-13 14:13:43 -06:00
committed by GitHub
parent a6414052a3
commit 0b044f729f
4 changed files with 46 additions and 1 deletions
+1 -1
View File
@@ -8760,7 +8760,7 @@ namespace Parser {
if (!jsDocDiagnostics) {
jsDocDiagnostics = [];
}
jsDocDiagnostics.push(...parseDiagnostics);
addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
}
currentToken = saveToken;
parseDiagnostics.length = saveParseDiagnosticsLength;
@@ -0,0 +1,16 @@
//// [tests/cases/conformance/jsdoc/errorIsolation.ts] ////
=== errorIsolation.js ===
const async = { doSomething: _ => {} };
>async : Symbol(async, Decl(errorIsolation.js, 0, 5))
>doSomething : Symbol(doSomething, Decl(errorIsolation.js, 0, 15))
>_ : Symbol(_, Decl(errorIsolation.js, 0, 28))
async.doSomething(
>async.doSomething : Symbol(doSomething, Decl(errorIsolation.js, 0, 15))
>async : Symbol(async, Decl(errorIsolation.js, 0, 5))
>doSomething : Symbol(doSomething, Decl(errorIsolation.js, 0, 15))
/***/
() => {}
);
@@ -0,0 +1,21 @@
//// [tests/cases/conformance/jsdoc/errorIsolation.ts] ////
=== errorIsolation.js ===
const async = { doSomething: _ => {} };
>async : { doSomething: (_: any) => void; }
>{ doSomething: _ => {} } : { doSomething: (_: any) => void; }
>doSomething : (_: any) => void
>_ => {} : (_: any) => void
>_ : any
async.doSomething(
>async.doSomething( /***/ () => {}) : void
>async.doSomething : (_: any) => void
>async : { doSomething: (_: any) => void; }
>doSomething : (_: any) => void
/***/
() => {}
>() => {} : () => void
);
@@ -0,0 +1,8 @@
// @noEmit: true
// @checkJs: true
// @filename: errorIsolation.js
const async = { doSomething: _ => {} };
async.doSomething(
/***/
() => {}
);