-
-
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
[theme] Fix typing for theme.spacing #20435
Conversation
Details of bundle changes.Comparing: a2b2463...d581413 Details of page changes
|
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.
https://github.com/mui-org/material-ui/blob/52b80a0b29fe37184bcf1ab1c88bee40958fd197/packages/material-ui/src/styles/createSpacing.d.ts#L7
When passing one argument the return value can be a string now, need to change that as well.
To not break stuff might want to use function overloads for that one
@merceyz So something like this? diff --git a/packages/material-ui/src/styles/createSpacing.d.ts b/packages/material-ui/src/styles/createSpacing.d.ts
index bce50f88a..8beed9bff 100644
--- a/packages/material-ui/src/styles/createSpacing.d.ts
+++ b/packages/material-ui/src/styles/createSpacing.d.ts
@@ -5,6 +5,7 @@ export type SpacingArgument = number;
export interface Spacing {
(): number;
(value: SpacingArgument): number;
+ (value: SpacingArgument): string;
(topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
(top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
( |
We can unify the call signatures in that case: |
Well if you do it like this, you wont be changing the return type for anyone using (value: number): number;
(value: string): string; |
Oh definitely, with the solution, it looks obvious, thanks for taking the time 👌. It might change with #16205. |
Calling |
@m4theushw 👍 smart |
fd5b9ae
to
d581413
Compare
@m4theushw Thanks! |
This PR complements #20408