microsoft / microsoft/TypeScript
Path based Code navigation to /index.js seems broken
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
- VSCode Version: 1.42.1
- OS Version: Mac OS
Steps to Reproduce:
Code navigation seems broken when you import by path and the file is actually in an index.js file.
There are a couple of scenarios relevant to developing in react-native
- import from another package in a monorepo
import SomeComponent from 'common-lib/Router, when the file ispackages/common-lib/src/Router/index.js - import in the same package
import SomeComponent from 'modules/Router, when the file issrc/modules/Router/index.js import SomeComponent from 'modules/Router, when the file is not actually index.jssrc/modules/Router/index.ios.jsandsrc/modules/Router/index.android.js
In general, what works is loading a file name by name (not an index.js file)
What doesn't work is loading a file by path that is actually an index.js, index.native.js, index.ios.js, index.android.js etc file
My code structure is
root
packages
mobile
server
src
server
shared
common-lib
There is some history here that is not ideal. But ok.
packages/server jsconfig.json
{
"compilerOptions": {
"target": "es2017",
"allowSyntheticDefaultImports": false,
"baseUrl": ".",
"paths": {
"common-lib/*": ["../common-lib/*"],
"mobile/*": ["../mobile/*"],
"modules/*": ["./src/shared/modules/*"],
"components/*": ["./src/shared/components/*"],
"router/*": ["./src/shared/router/*"],
"server/*": ["./src/server*"],
"App": ["./src/App"]
}
},
"exclude": ["node_modules", "../../node_modules", "build"]
}
Does this issue occur when all extensions are disabled?: Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the three import cases with the provided packages/server jsconfig.json, including index.js and platform-specific index files. Trace code navigation for path-based imports and compare it with named-file imports; done means navigation reaches the resolved module in each listed scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100