Only bind JSDoc typedefs in JavaScript files

This commit is contained in:
Andy Hanson 2017-04-03 15:00:40 -07:00
parent 9c9b659f44
commit 24b09d8502
5 changed files with 69 additions and 1 deletions

View file

@ -1910,7 +1910,9 @@ namespace ts {
// 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,
// 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
// and then potentially add the symbol to an appropriate symbol table. Possible

View 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;

View 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))

View 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

View 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;