Skip to content

Commit 0c60824

Browse files
author
Andy Hanson
committed
Set @typedef parent pointer, but still do not bind a symbol
1 parent 76955ce commit 0c60824

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/compiler/binder.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ namespace ts {
439439
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
440440
// and this case is specially handled. Module augmentations should only be merged with original module definition
441441
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
442-
const isJSDocTypedefInJSDocNamespace = node.kind === SyntaxKind.JSDocTypedefTag &&
442+
const isJSDocTypedefInJSDocNamespace = isInJavaScriptFile(node) && node.kind === SyntaxKind.JSDocTypedefTag &&
443443
(node as JSDocTypedefTag).name &&
444444
(node as JSDocTypedefTag).name.kind === SyntaxKind.Identifier &&
445445
((node as JSDocTypedefTag).name as Identifier).isInJSDocNamespace;
@@ -1913,9 +1913,7 @@ namespace ts {
19131913
// Here the current node is "foo", which is a container, but the scope of "MyType" should
19141914
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
19151915
// and skip binding this tag later when binding all the other jsdoc tags.
1916-
if (isInJavaScriptFile(node)) {
1917-
bindJSDocTypedefTagIfAny(node);
1918-
}
1916+
bindJSDocTypedefTagIfAny(node);
19191917

19201918
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
19211919
// and then potentially add the symbol to an appropriate symbol table. Possible
@@ -2003,7 +2001,7 @@ namespace ts {
20032001
// for typedef type names with namespaces, bind the new jsdoc type symbol here
20042002
// because it requires all containing namespaces to be in effect, namely the
20052003
// current "blockScopeContainer" needs to be set to its immediate namespace parent.
2006-
if ((<Identifier>node).isInJSDocNamespace) {
2004+
if (isInJavaScriptFile(node) && (<Identifier>node).isInJSDocNamespace) {
20072005
let parentNode = node.parent;
20082006
while (parentNode && parentNode.kind !== SyntaxKind.JSDocTypedefTag) {
20092007
parentNode = parentNode.parent;
@@ -2149,7 +2147,7 @@ namespace ts {
21492147
case SyntaxKind.InterfaceDeclaration:
21502148
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes);
21512149
case SyntaxKind.JSDocTypedefTag:
2152-
if (!(<JSDocTypedefTag>node).fullName || (<JSDocTypedefTag>node).fullName.kind === SyntaxKind.Identifier) {
2150+
if (isInJavaScriptFile(node) && (!(<JSDocTypedefTag>node).fullName || (<JSDocTypedefTag>node).fullName.kind === SyntaxKind.Identifier)) {
21532151
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
21542152
}
21552153
break;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// Just testing that this doesn't cause an exception due to the @typedef contents not having '.parent' set.
4+
// But it isn't bound to a Symbol so find-all-refs will return nothing.
5+
6+
/////** @typedef {Object} [|T|] */
7+
////function foo() {}
8+
9+
verify.referenceGroups(test.ranges()[0], undefined);

0 commit comments

Comments
 (0)