diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 499659bc331..5b4a778e8ce 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -34,12 +34,12 @@ namespace ts.GoToDefinition { // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. if (typeChecker.getRootSymbols(symbol).some(s => symbolMatchesSignature(s, calledDeclaration)) || - // TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias - symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) { + // TODO: GH#25533 Following check shouldn't be necessary if 'require' is an alias + symbol.declarations && symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) { return [sigInfo]; } else { - const defs = getDefinitionFromSymbol(typeChecker, symbol, node)!; + const defs = getDefinitionFromSymbol(typeChecker, symbol, node) || emptyArray; // For a 'super()' call, put the signature first, else put the variable first. return node.kind === SyntaxKind.SuperKeyword ? [sigInfo, ...defs] : [...defs, sigInfo]; } diff --git a/tests/cases/fourslash/goToDefinition_mappedType.ts b/tests/cases/fourslash/goToDefinition_mappedType.ts new file mode 100644 index 00000000000..45bd3b91a5e --- /dev/null +++ b/tests/cases/fourslash/goToDefinition_mappedType.ts @@ -0,0 +1,7 @@ +/// + +////interface I { /*def*/m(): void; }; +////declare const i: { [K in "m"]: I[K] }; +////i.[|/*ref*/m|](); + +verify.goToDefinition("ref", "def");