csstype
csstype copied to clipboard
Strict types
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.
Why did the author even add this (string & {}) ?
from the README:
- TypeScript hack for autocompletion
Uses(string & {})for literal string unions and(number & {})for literal number unions (related issue). UtilizePropertyValue<T>to unpack types from e.g.(string & {})tostring.
@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: https://github.com/frenic/csstype/issues/90#issuecomment-707851935
I found the answer because of your comment.
@Farnsi What the criteria of the "strict" in this case?
@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