-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[material-ui][styles] convert createPalette code to typescript #44173
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-44173--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
@@ -1,145 +0,0 @@ | |||
export type PaletteMode = 'light' | 'dark'; |
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.
Moved code in this file to createPalette.ts
A700: string; | ||
} | ||
|
||
export {}; |
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.
Does this have a purpose?
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.
Not really sure, i just copy pasted entire code from createPalette.d.ts to this file.
lightShade = 300, | ||
darkShade = 700, | ||
}: PaletteAugmentColorOptions): PaletteColor => { | ||
const colorInput = { ...color } as PaletteColor; |
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.
There are 4 or 5 places with type casting, especially this one and the createPalette
return type. Can we try avoiding type casting without breaking public types?
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.
Yeah i agree, there are lot of type castings, initially i tried to avoid castings but it seemed impossible without breaking public api's.
For example: let's take this type here. I applied casting to shade
type here to make sure type of shade
is one of keys in intent
. So to remove this casting, we need to change type of shade
to number | keyof PaletteColor
from number | string
.
So if we change shade
type, we need to change type of lightShade
and darkShade
from number | string
to number | keyof PaletteColor
as both are passed as shade
here and this results in changing PaletteAugmentColorOptions
type which is a public api.
Let me know, if you need explainations for other type castings
Was going through this PR comments and this comment was the motivation to open the PR