Skip to content

Completions get lost for CSSProperties[K] in interface with <K extends keyof CSSProperties> #17047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rozzzly opened this issue Jul 10, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@rozzzly
Copy link

rozzzly commented Jul 10, 2017

Consider the following:

interface CSSProperties {
    height?: any;
    color?: any;
    position?: (
        | 'static'
        | 'absolute'
        | 'fixed'
        | 'relative'
        | 'initial'
        | 'inherit'
    );
    // .... rest of css properties, some of them with defined acceptable values (like `position`)
}

export interface CSSDeclaration<K extends keyof CSSProperties> {
    propertyName: K;
    value: CSSProperties[K];
}

function proclaim<T extends keyof CSSProperties>(decl: CSSDeclaration<T>): CSSDeclaration<T> {
  return decl;
 }
proclaim({
    propertyName: 'position', // you get completions here, OK
    value: '??' // no completions here, :sadface:
});

The type checker will error if you put a value other than one of those defined in CSSProperties, so obviously the type doesn't get lost along the way, but the completions do.

version: 2.5.0-dev.20170707 and whatever the playground is running

@mhegazy
Copy link
Contributor

mhegazy commented Aug 26, 2017

looks like the same issue as #11997

@mhegazy mhegazy added the Duplicate An existing issue was already created label Aug 26, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 11, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 11, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants