Merge pull request #14997 from Microsoft/jsdoc
Only bind JSDoc typedefs in JavaScript files
This commit is contained in:
commit
7de3539b49
|
@ -1910,7 +1910,9 @@ namespace ts {
|
||||||
// Here the current node is "foo", which is a container, but the scope of "MyType" should
|
// Here the current node is "foo", which is a container, but the scope of "MyType" should
|
||||||
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
|
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
|
||||||
// and skip binding this tag later when binding all the other jsdoc tags.
|
// and skip binding this tag later when binding all the other jsdoc tags.
|
||||||
bindJSDocTypedefTagIfAny(node);
|
if (isInJavaScriptFile(node)) {
|
||||||
|
bindJSDocTypedefTagIfAny(node);
|
||||||
|
}
|
||||||
|
|
||||||
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
|
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
|
||||||
// and then potentially add the symbol to an appropriate symbol table. Possible
|
// and then potentially add the symbol to an appropriate symbol table. Possible
|
||||||
|
|
19
tests/baselines/reference/jsdocInTypeScript.js
Normal file
19
tests/baselines/reference/jsdocInTypeScript.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
//// [jsdocInTypeScript.ts]
|
||||||
|
// JSDoc typedef tags are not bound TypeScript files.
|
||||||
|
/** @typedef {function} T */
|
||||||
|
declare const x: T;
|
||||||
|
|
||||||
|
class T {
|
||||||
|
prop: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
x.prop;
|
||||||
|
|
||||||
|
|
||||||
|
//// [jsdocInTypeScript.js]
|
||||||
|
var T = (function () {
|
||||||
|
function T() {
|
||||||
|
}
|
||||||
|
return T;
|
||||||
|
}());
|
||||||
|
x.prop;
|
19
tests/baselines/reference/jsdocInTypeScript.symbols
Normal file
19
tests/baselines/reference/jsdocInTypeScript.symbols
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
=== tests/cases/compiler/jsdocInTypeScript.ts ===
|
||||||
|
// JSDoc typedef tags are not bound TypeScript files.
|
||||||
|
/** @typedef {function} T */
|
||||||
|
declare const x: T;
|
||||||
|
>x : Symbol(x, Decl(jsdocInTypeScript.ts, 2, 13))
|
||||||
|
>T : Symbol(T, Decl(jsdocInTypeScript.ts, 2, 19))
|
||||||
|
|
||||||
|
class T {
|
||||||
|
>T : Symbol(T, Decl(jsdocInTypeScript.ts, 2, 19))
|
||||||
|
|
||||||
|
prop: number;
|
||||||
|
>prop : Symbol(T.prop, Decl(jsdocInTypeScript.ts, 4, 9))
|
||||||
|
}
|
||||||
|
|
||||||
|
x.prop;
|
||||||
|
>x.prop : Symbol(T.prop, Decl(jsdocInTypeScript.ts, 4, 9))
|
||||||
|
>x : Symbol(x, Decl(jsdocInTypeScript.ts, 2, 13))
|
||||||
|
>prop : Symbol(T.prop, Decl(jsdocInTypeScript.ts, 4, 9))
|
||||||
|
|
19
tests/baselines/reference/jsdocInTypeScript.types
Normal file
19
tests/baselines/reference/jsdocInTypeScript.types
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
=== tests/cases/compiler/jsdocInTypeScript.ts ===
|
||||||
|
// JSDoc typedef tags are not bound TypeScript files.
|
||||||
|
/** @typedef {function} T */
|
||||||
|
declare const x: T;
|
||||||
|
>x : T
|
||||||
|
>T : T
|
||||||
|
|
||||||
|
class T {
|
||||||
|
>T : T
|
||||||
|
|
||||||
|
prop: number;
|
||||||
|
>prop : number
|
||||||
|
}
|
||||||
|
|
||||||
|
x.prop;
|
||||||
|
>x.prop : number
|
||||||
|
>x : T
|
||||||
|
>prop : number
|
||||||
|
|
9
tests/cases/compiler/jsdocInTypeScript.ts
Normal file
9
tests/cases/compiler/jsdocInTypeScript.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// JSDoc typedef tags are not bound TypeScript files.
|
||||||
|
/** @typedef {function} T */
|
||||||
|
declare const x: T;
|
||||||
|
|
||||||
|
class T {
|
||||||
|
prop: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
x.prop;
|
Loading…
Reference in a new issue