-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
classnames also accept undefined as value #751
Conversation
@@ -32,7 +32,7 @@ export interface ArrayClassNameArg extends Array<ClassNameArg> {} | |||
|
|||
export type ClassNameArg = | |||
| undefined | null | boolean | string | |||
| { [key: string]: boolean } | |||
| { [key: string]: boolean | undefined } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this need to support all of these types (undefined | null | boolean | string
) as values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need any
, as described in #746.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while any
is technically correct I doubt we should actually recommend it, typings give us power to restrict usages to sane ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's better with undefined | null | boolean | string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
Why was type
I now have to type one of the following just to make TS happy again (which I find unnecessary):
Actually type |
Imho relaying on auto bool coercion for numbers there is not the best way to do. While it ofc works in JavaScript, type systems should strive to be more explicit about such things and I would consider the current lack of number support a good thing. |
What:
Why:
How:
Checklist: