Skip to content

No object literal completions for type parameter constrained to mapped type #16136

Closed

Description

Isolated from this StackOverflow issue

interface Foo {
    foo(): void;
}

declare function f<T extends Partial<Foo>>(x: T): T;

f({
    /*$*/
})

Request completions at the cursor in the above sample.

Expected: foo is a completion.
Actual: No completions.

Activity

  1. changed the title [-]No object literal completions for object constrained to mapped type[/-] [+]No object literal completions for type parameter constrained to mapped type[/+] on May 30, 2017
  2. DanielRosenwasser commented on Sep 19, 2017

    @DanielRosenwasser
    MemberAuthor

    I believe that this is because {} fulfills the constraint so that we end up with an inference for T which causes us to give completions from {} instead of the constraint of T.

  3. DanielRosenwasser commented on Jul 25, 2025

    @DanielRosenwasser
    MemberAuthor

    Seems to work now - I feel like Andrew Branch (@andrewbranch) might have fixed this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: LS: Completion ListsThe issue relates to showing completion lists in an editorExperience EnhancementNoncontroversial enhancementsFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions