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.

Open
#55,593 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
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:

  1. npm install openai
  2. import OpenAI from 'openai'; type Foo = OpenAI.Chat.Completion
  3. cmd-click on "Completion"
  4. observe a dialog pop up, offering you the interface Completion or the namespace Completion

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.