microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.08k stars 12.37k forks source link

JS Find function definition involving a function generator #39400

Open mitivic opened 4 years ago

mitivic commented 4 years ago

TS Template added by @mjbvz

TypeScript Version: 4.0.0-dev.20200702

Search Terms


Issue Type: Bug

// x.js
module.exports.a = () => {return ()=>{}};

// y.js
let n = require('./x.js');
module.exports.b = n.a();

// anywhere other than y.js
let m = require('./y.js');
let c = m.b(); // ctrl-click b

ctrl-click b leads to 2 definitions and the default is a's definition instead of b's

VS Code version: Code 1.46.1 (cd9ea6488829f560dc949a8b2fb789f3cdc05f5d, 2020-06-17T21:13:20.174Z) OS version: Windows_NT x64 10.0.17134

Extensions (15) Extension|Author (truncated)|Version ---|---|--- project-manager|ale|11.1.0 vscode-eslint|dba|2.1.5 clipboard-manager|Edg|1.4.2 vscode-npm-script|eg2|0.3.12 vscode-test-explorer|hbe|2.19.1 vscode-heroku|iva|1.2.6 docthis|joe|0.7.1 mongodb-vscode|mon|0.0.4 csharp|ms-|1.22.1 mssql|ms-|1.9.0 python|ms-|2020.6.91350 cpptools|ms-|0.28.3 prettier-now|rem|1.4.9 tabnine-vscode|Tab|2.8.6 poor-mans-t-sql-formatter-vscode|Tao|1.6.10
mjbvz commented 4 years ago

You example code is not valid JavaScript:

Screen Shot 2020-07-02 at 11 51 25 AM

Please provide a working example

mitivic commented 4 years ago

as edit:

// x.js
module.exports.a = () => {return ()=>{}};

// y.js
let n = require('./x.js');
module.exports.b = n.a();

// anywhere
let m = require('./y.js');
let c = m.b(); // ctrl-click b

It seems "require" is relevant to this problem.

mjbvz commented 4 years ago

Thanks @mitivic. I can reproduce this issue

Just to be clear, in your example you expect go to definition on b to jump to module.exports.b = n.a(); in y.js, correct?

mitivic commented 4 years ago

YES