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

Strict types #176

Open
Farnsi opened this issue Mar 16, 2023 · 4 comments
Open

Strict types #176

Farnsi opened this issue Mar 16, 2023 · 4 comments

Comments

@Farnsi
Copy link

Farnsi commented Mar 16, 2023

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.

@heleg
Copy link

heleg commented Jul 30, 2023

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

@meyer
Copy link

meyer commented Jul 30, 2023

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.

@heleg
Copy link

heleg commented Jul 30, 2023

@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?

@Farnsi
Copy link
Author

Farnsi commented Jul 31, 2023

@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

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