frenic / csstype

Strict TypeScript and Flow types for style based on MDN data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strict types

Farnsi opened this issue · comments

It would be great if this nice lib could export strict types, without(string & {}) everything.

Usage e.g. with import type * as CSS from 'csstype/strict';

If a non strict type is necessary, we could add it manually with a union or import the non-strict csstype.

commented

Why did the author even add this (string & {}) ?

commented

from the README:

  • TypeScript hack for autocompletion
    Uses (string & {}) for literal string unions and (number & {}) for literal number unions (related issue). Utilize PropertyValue<T> to unpack types from e.g. (string & {}) to string.
commented

@meyer Thank you very much. Personally I was confused not by string | {} union but by string fallback in common.
I had the very same question: #90 (comment)
I found the answer because of your comment.

@Farnsi What the criteria of the "strict" in this case?

commented

@heleg strict should be an export without string | {}, only defined properties

Example:

  export type Height<TLength = (string & {}) | 0> =
    | Globals
    | TLength
    | "-moz-max-content"
    | "-moz-min-content"
    | "-webkit-fit-content"
    | "auto"
    | "fit-content"
    | "max-content"
    | "min-content"
//    | (string & {});  // <--------- STRICT without that