Skip to content
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

Intellisense not working (TS) #42

Closed
oldrich-s opened this issue Apr 15, 2018 · 5 comments
Closed

Intellisense not working (TS) #42

oldrich-s opened this issue Apr 15, 2018 · 5 comments

Comments

@oldrich-s
Copy link

import * as CSS from 'csstype';

const style: CSS.Properties = {
  alignSelf: 'stretsh', // Type error on value
  colour: 'white', // Type error on property
};

alignSelf from the frontpage does not throw an error because string is allowed:

type AlignSelfProperty = Globals | SelfPosition | "auto" | "baseline" | "normal" | "stretch" | string;

Also with the latest typescript 2.8.1 and csstype 2.2.0 and the latest VSCode I do not get any intellisense for alignSelf. Does it work for you?

@oldrich-s
Copy link
Author

I have found the issue:

type Globals = "inherit" | "initial" | "revert" | "unset";

type SelfPosition = "center" | "end" | "flex-end" | "flex-start" | "self-end" | "self-start" | "start";

type AlignSelfProperty = Globals | SelfPosition | "auto" | "baseline" | "normal" | "stretch"// | string;

interface CSSTest {
    alignSelf?: AlignSelfProperty;
}

const style: CSSTest = {
    alignSelf: 'stretch'
};

When I comment out | string, the intellisense works as expected. So it looks like that adding string to the types ruins intellisense...

@frenic
Copy link
Owner

frenic commented Apr 15, 2018

Oh, I missed that in the example. Should change it. Thanks for noticing. The spec tells us that align-self can use space separated keywords and we don't support that yet. That's why it falls back to | string. I've started a PR #22 where I aim to solve this.

I agree that autocompletion in VSCode should work even if it contains | string. But it doesn't and there's an issue for that. @andy-ms commented that TypeScript won't fix it either for some reason.

The type "foo" | "bar" | string is equivalent to the string type and now gets simplified early on. So all we see when querying the type checker for the type of x is string. So, this can't be fixed.

Hopefully we can make them reconsider.

frenic added a commit that referenced this issue Apr 15, 2018
@frenic
Copy link
Owner

frenic commented Apr 20, 2018

Closing because autocompletion is in the hands of TypeScript and we can't do much about it.

@dmahnkopf
Copy link

dmahnkopf commented Jan 10, 2020

@frenic, would you consider rewriting the concerned types as proposed in this TypeScript issue comment?

@frenic
Copy link
Owner

frenic commented Jan 13, 2020

@dmahnkopf That hack is already in 3.0.0-beta.1. Related #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants