-
Notifications
You must be signed in to change notification settings - Fork 75
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
Exact value validation #121
Comments
The
|
Very good point, thanks. I will do some exploring and testing when I will have some time and I will come back with results. |
My exploring about this problem is, that TypeScript has limit for unions something up to 100 thousands, so basically it isn't enough even for validation color with hex format (#000000). And even when I was testing performance, IDE wasn't slow, but response time when object got underline was really high with complex unions up to 90 thousands. So thank you for comment, I'm closing this thread. |
I would like to ask if you consider exact value validation. CSS properties have exact defined form by W3, so for example the display property should have one of defined values like "contents" | "list-item" | "none" and so on. From my point of view the Display type should looks like this:
Without string or (string & {}). I know that the type (string & {}) is only TypeScript hack for now, but to restrict the values only for one of these and use full potentional of TypeScript would be better to don't use string or (string & {}) in type definition. Because you can't give to the developers only restricted values and prevent possible mistakes and therefore TypeScript exists.
Since TypeSctipt 4.1 is possible even to check string format. So for example for size we can have exact value checking like so:
So with this new functionality we can check exact string format such as '2px solid #000', etc. With this, we can get rid of most strings and (string & {}) and check all CSS properties as CSS validator does.
Conclusion:
My goal is to validate all values of CSS properties with TypeScript and prevent errors in CSS before run an application.
The text was updated successfully, but these errors were encountered: