microsoft / microsoft/TypeScript
Go-to-definition on interfaces shadowed by namespaces opens a selection dialog instead of going to the interface, when used as one.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.81.1
- OS Version: 13.4.1 (c)
Steps to Reproduce:
npm install openaiimport OpenAI from 'openai'; type Foo = OpenAI.Chat.Completion- cmd-click on "Completion"
- observe a dialog pop up, offering you the interface
Completionor the namespaceCompletion
Desired behavior:
Jump directly to the definition of the interface Completion, since that is how it's being used there.
Context:
Libraries like stripe and openai use the pattern of shadowing interfaces with namespaces when describing large JSON objects generated from their OpenAPI specs.
This was a tradeoff made because the alternatives are worse: you'd otherwise have to generate long, Java-like names (eg; ChatCompletionChoiceMessageFunctionCall), try to come up with minimal names (which could easily clash with future objects, causing backwards-compatibility issues), move all sub-objects into other files (which'd quickly get unreadable), or define all objects inline (which makes it difficult-to-impossible to directly reference object types whose parents are nullable/optional, members of unions, etc).
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
Reproduce the behavior with npm install openai and import OpenAI from 'openai'; type Foo = OpenAI.Chat.Completion, then use cmd-click on Completion. Investigate the go-to-definition entry point and symbol resolution for the interface and namespace; done means this usage opens the interface directly without a selection dialog.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100