Microsoft/TypeScript

String completions for `keyof T` not shown when an object literal `T` was provided in a prior argument

Open

#47.479 aberto em 17 de jan. de 2022

Ver no GitHub
 (2 comments) (1 reaction) (0 assignees)TypeScript (6.726 forks)batch import
Domain: LS: Completion ListsExperience EnhancementHelp WantedSuggestion

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

Description

Bug Report

🔎 Search Terms

Incorrect suggestions

🕗 Version & Regression Information

This bug occurs in v4.5.4 and nightly version. (Possibly every version)

⏯ Playground Link

Playground link with relevant code

💻 Code

type Methods = {
    [key: string]: (param: {
        apple: 'apple'
    }) => any
}

function testFunc<M extends Methods>(options: {
    methods: M,
    keys: keyof M
}): void {}

testFunc({
    methods: {
        myMethod: (param) => {
            console.log(param.apple)
        }
    },
    keys: 
})

🙁 Actual behavior

When hovering the word "keys" in line 18, it shows its type is "myMethod". And when i start typing for its value, "myMethod" is not being suggested.

🙂 Expected behavior

"myMethod" should be suggested when typing the value in line 18.

Guia do colaborador