Skip to content

Optional and already-fulfilled properties should have lower priorities than required properties #29868

Closed
@DanielRosenwasser

Description

@DanielRosenwasser

I ran into this while trying to implement TypeScript's ParseConfigFileHost with an object spread, and I've been seeing this come up in my experience in general.

interface Something {
    a?: number;
    b: number;
    c?: string;
    d: string;
}

const thing: Something = {
    /*$*/    
}

Expected: Completions show b, d, a, c.
Actual: Completions show a, b, c, d.

image

Furthermore, already fulfilled properties should be even lower than optional properties.

interface Something {
    a?: number;
    b: number;
    c?: string;
    d: string;
}

const foo = {
    a: 100,
    b: 100,
}

const thing: Something = {
    ...foo,
    /*$*/    
}

Expected: d, c, a, b
Actual: a, b, c, d

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Completion ListsThe issue relates to showing completion lists in an editorEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions