-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Remove classes optional typings #3894
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
Remove classes optional typings #3894
Conversation
|
@dzearing I think this isn't as useful as hoped though and basically doesn't change much. Because of the dynamic property creation it seems it'll be difficult to type |
|
@Markionium is there a need to make ColorClassNames a partial? |
|
@dzearing I was hoping it wasn't but TS won't allow me to assign export const ColorClassNames: Partial<IColorClassNames> = {};I tried to "fix" it by reducing instead of building it up with a TS is technically doing the correct thing since removing a color from the I also considered changing the ColorClassNames into something like the following, so we could do something like below, but it leaves me with the same issue around the dynamic properties. interface ColorClasses {
text: string;
textHover: string;
background: string;
backgroundHover: string;
border: string;
borderHover: string;
}
export type IColorClassesNames = {[key in keyof IPalette]: ColorClasses};PS: It's not such a big issue as i resolved on our side, but perhaps still worth it to fix it somehow? |
| } | ||
|
|
||
| export const ColorClassNames: IColorClassNames = {}; | ||
| export const ColorClassNames: Partial<IColorClassNames> = {}; |
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.
Shouldn't this be:
export const ColorClassNames: IColorClassNames = {} as IColorClassNames;Then in your code, you don't need to treat it as an non-optional?
| */ | ||
| function _defineGetter( | ||
| obj: IColorClassNames, | ||
| obj: Partial<IColorClassNames>, |
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.
You don't need this if you do what I said above.
dzearing
left a comment
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.
If you tweak it a little, I think it will do what you want.
Pull request checklist
$ npm run changeDescription of changes
Changes
ColorClassNamesto usePartial<T>Focus areas to test
(optional)