-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[code-infra] Improve proptypes-generation #40617
Conversation
Netlify deploy previewhttps://deploy-preview-40617--material-ui.netlify.app/ Bundle size report |
I'm not aware of such limitations. But I haven't had much to do with the typescript-to-proptypes package so far. |
@@ -125,6 +125,7 @@ function checkType({ | |||
if (project.checker.isArrayType(type)) { | |||
// @ts-ignore | |||
const arrayType: ts.Type = project.checker.getElementTypeOfArrayType(type); | |||
|
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.
@@ -94,7 +96,7 @@ export function createInterfaceType(init: { | |||
} | |||
|
|||
export function createLiteralType(init: { | |||
value: unknown; | |||
value: string | number | ts.PseudoBigInt; |
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.
This Type come from observing all the createLiteralType()
call
two of them only take string, the last one as this typing for it's input value
} | ||
|
||
return type.type; | ||
return getTypeHash(type); |
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.
Here is the root cause of the issue. If you do the union of two interfaces, they were erased because their type.type
is "InterfaceNode"
so only one of the two survive to the _.uniqBy
I created a getTypeHash
that generate a hash in a recursive way to support interface, union and array
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.
Found a typo, but it looks good overall!
@@ -149,6 +150,13 @@ export function uniqueUnionTypes(node: UnionType): UnionType { | |||
return `${type.type}.${type.instance}`; | |||
} | |||
|
|||
if (type.type === 'InterfaceNode') { | |||
// Allows union of mulitple interface nodes |
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.
// Allows union of mulitple interface nodes | |
// Allows union of multiple interface nodes |
Simple reproduction of this issue mui/mui-x#11679
I set two way to define
ChartSeries<T>
but in bot case I only get one type (not the same depending on the union chosen)However TypeScript seems to correctly understand the series type and its data type
@mui/code-infra Is it a known limitation (do you know where it comes from)? If not, I can investigate a bit further