typestyle / typestyle

Making CSS Typesafe 🌹

Home Page:https://typestyle.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code completion is broken

barinbritva opened this issue · comments

Hi @basarat,

First of all, thanks for your awesome library.
I decided to use it in my new project. But I've run into a problem. Here is an example:

import {style} from 'typestyle';

export const styles = {
  header: style({
    // There is no IDE hints. Display type is string now
    display: '',
  })
};

Type definition for display, which comes from csstype is

export type DisplayProperty = 
  | Globals
  | DisplayOutside
  | DisplayInside
  | DisplayInternal
  | DisplayLegacy
  | "contents"
  | "list-item"
  | "none"
  | string;

According to this bug microsoft/TypeScript#29729 it happens because of | string which redundantes whole the definition to a simple string.

In fresher version of csstype the problem has been fixed. Now the definition looks like:

  export type Display =
    | Globals
    | DataType.DisplayOutside
    | DataType.DisplayInside
    | DataType.DisplayInternal
    | DataType.DisplayLegacy
    | "contents"
    | "list-item"
    | "none"
    | (string & {});

Changing string to (string & {}) fixes the issue. Of course, I mean not only the one property, but all the similar definitions.

I believe, to fix the code completion in typestyle it will be enough to update version of csstype.

Also, it would be even more type safe to get rid of string option at all. I described the situation here - frenic/csstype#149