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/services/goToDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ namespace ts.GoToDefinition {
const sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
// For a function, if this is the original function definition, return just sigInfo.
// If this is the original constructor definition, parent is the class.
return typeChecker.getRootSymbols(symbol).some(s => calledDeclaration.symbol === s || calledDeclaration.symbol.parent === s)
return typeChecker.getRootSymbols(symbol).some(s => calledDeclaration.symbol === s || calledDeclaration.symbol.parent === s) ||
// 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))
? [sigInfo]
: [sigInfo, ...getDefinitionFromSymbol(typeChecker, symbol, node)];
}
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/fourslash/goToDefinitionSignatureAlias_require.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true

// @Filename: /a.js
////module.exports = function /*f*/f() {}

// @Filename: /b.js
////const f = require("./a");
////[|/*use*/f|]();

verify.goToDefinition("use", "f");