Skip to content

Properties in object literal key completion list aren't filtered when a prior argument supplies a mapped type key #35702

Closed
@simonhaenisch

Description

@simonhaenisch
  • VSCode Version: 1.41.0
  • OS Version: macOS 10.14.6

Steps to Reproduce:

>> Playground Link

interface CustomElements {
    'component-one': {
        foo?: string;
    },
    'component-two': {
        bar?: string;
    }
}

interface Options<T extends keyof CustomElements> {
    props: CustomElements[T];
}

function create<T extends keyof CustomElements>(name: T, options: Options<T>) {
    return { name, options };
}

create('component-one', { props: { /* trigger intellisense here */ } });

const opts: Options<'component-one'> = {
    props: { /* and here */ }
}

The type of props in the create call is correctly narrowed down to CustomElements['component-one'] by the type system, however Intellisense suggests the props of all fields of CustomElements:

This does not happen when creating an object of that type:

Does this issue occur when all extensions are disabled?: Yes

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editor

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions