Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/baselines/reference/jsdocInTypeScript.js
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions tests/baselines/reference/jsdocInTypeScript.symbols
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions tests/baselines/reference/jsdocInTypeScript.types
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions tests/cases/compiler/jsdocInTypeScript.ts
Original file line number Diff line number Diff line change
@@ -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;