mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
Don't show a definition at a 'require' call (#23822)
This commit is contained in:
parent
deef6cd88c
commit
724e656acb
@ -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)];
|
||||
}
|
||||
|
||||
@ -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");
|
||||
Loading…
x
Reference in New Issue
Block a user