Skip to content

Commit 24b09d8

Browse files
author
Andy Hanson
committed
Only bind JSDoc typedefs in JavaScript files
1 parent 9c9b659 commit 24b09d8

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed

src/compiler/binder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,9 @@ namespace ts {
19101910
// Here the current node is "foo", which is a container, but the scope of "MyType" should
19111911
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
19121912
// and skip binding this tag later when binding all the other jsdoc tags.
1913-
bindJSDocTypedefTagIfAny(node);
1913+
if (isInJavaScriptFile(node)) {
1914+
bindJSDocTypedefTagIfAny(node);
1915+
}
19141916

19151917
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
19161918
// and then potentially add the symbol to an appropriate symbol table. Possible
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [jsdocInTypeScript.ts]
2+
// JSDoc typedef tags are not bound TypeScript files.
3+
/** @typedef {function} T */
4+
declare const x: T;
5+
6+
class T {
7+
prop: number;
8+
}
9+
10+
x.prop;
11+
12+
13+
//// [jsdocInTypeScript.js]
14+
var T = (function () {
15+
function T() {
16+
}
17+
return T;
18+
}());
19+
x.prop;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/jsdocInTypeScript.ts ===
2+
// JSDoc typedef tags are not bound TypeScript files.
3+
/** @typedef {function} T */
4+
declare const x: T;
5+
>x : Symbol(x, Decl(jsdocInTypeScript.ts, 2, 13))
6+
>T : Symbol(T, Decl(jsdocInTypeScript.ts, 2, 19))
7+
8+
class T {
9+
>T : Symbol(T, Decl(jsdocInTypeScript.ts, 2, 19))
10+
11+
prop: number;
12+
>prop : Symbol(T.prop, Decl(jsdocInTypeScript.ts, 4, 9))
13+
}
14+
15+
x.prop;
16+
>x.prop : Symbol(T.prop, Decl(jsdocInTypeScript.ts, 4, 9))
17+
>x : Symbol(x, Decl(jsdocInTypeScript.ts, 2, 13))
18+
>prop : Symbol(T.prop, Decl(jsdocInTypeScript.ts, 4, 9))
19+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/jsdocInTypeScript.ts ===
2+
// JSDoc typedef tags are not bound TypeScript files.
3+
/** @typedef {function} T */
4+
declare const x: T;
5+
>x : T
6+
>T : T
7+
8+
class T {
9+
>T : T
10+
11+
prop: number;
12+
>prop : number
13+
}
14+
15+
x.prop;
16+
>x.prop : number
17+
>x : T
18+
>prop : number
19+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// JSDoc typedef tags are not bound TypeScript files.
2+
/** @typedef {function} T */
3+
declare const x: T;
4+
5+
class T {
6+
prop: number;
7+
}
8+
9+
x.prop;

0 commit comments

Comments
 (0)