Skip to content

Go-to-definition on interfaces shadowed by namespaces opens a selection dialog instead of going to the interface, when used as one. #55593

@rattrayalex

Description

@rattrayalex

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions