-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Change React.ReactElement<any> to React.ReactElement<unknown> #43402
Changes from 11 commits
f766a4c
4e3a8f7
b269f20
37340ed
2c996c7
c7b4c40
9168dcd
60c55e5
e5605f3
94f691e
6019f2a
b583310
7d3d548
9f1b74d
3ff9828
09f5298
c7483d7
4b9919d
4f2f5c1
d013bd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,7 +286,7 @@ export interface MuiRenderToStringResult { | |
} | ||
|
||
function render( | ||
element: React.ReactElement<any>, | ||
element: React.ReactElement<unknown>, | ||
configuration: ClientRenderConfiguration, | ||
): MuiRenderResult { | ||
const { container, hydrate, wrapper } = configuration; | ||
|
@@ -306,7 +306,7 @@ function render( | |
traceSync('forceUpdate', () => | ||
testingLibraryRenderResult.rerender( | ||
React.cloneElement(element, { | ||
'data-force-update': String(Math.random()), | ||
['data-force-update' as string]: String(Math.random()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if I understand correctly, this is casting the key, not the value 🤔 What's the error thrown without the cast? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of casting, i've tried to fix type error properly here =>09f5298 |
||
}), | ||
), | ||
); | ||
|
@@ -322,7 +322,7 @@ function render( | |
} | ||
|
||
function renderToString( | ||
element: React.ReactElement<any>, | ||
element: React.ReactElement<unknown>, | ||
configuration: ServerRenderConfiguration, | ||
): { container: HTMLElement; hydrate(): MuiRenderResult } { | ||
const { container, wrapper: Wrapper } = configuration; | ||
|
@@ -444,9 +444,9 @@ function createClock(defaultMode: 'fake' | 'real', config: ClockConfig): Clock { | |
|
||
export interface Renderer { | ||
clock: Clock; | ||
render(element: React.ReactElement<any>, options?: RenderOptions): MuiRenderResult; | ||
render(element: React.ReactElement<unknown>, options?: RenderOptions): MuiRenderResult; | ||
renderToString( | ||
element: React.ReactElement<any>, | ||
element: React.ReactElement<unknown>, | ||
options?: RenderOptions, | ||
): MuiRenderToStringResult; | ||
} | ||
|
@@ -586,7 +586,7 @@ export function createRenderer(globalOptions: CreateRendererOptions = {}): Rende | |
|
||
return { | ||
clock, | ||
render(element: React.ReactElement<any>, options: RenderOptions = {}) { | ||
render(element: React.ReactElement<unknown>, options: RenderOptions = {}) { | ||
if (!prepared) { | ||
throw new Error( | ||
'Unable to finish setup before `render()` was called. ' + | ||
|
@@ -601,7 +601,7 @@ export function createRenderer(globalOptions: CreateRendererOptions = {}): Rende | |
wrapper: createWrapper(options), | ||
}); | ||
}, | ||
renderToString(element: React.ReactElement<any>, options: RenderOptions = {}) { | ||
renderToString(element: React.ReactElement<unknown>, options: RenderOptions = {}) { | ||
if (!prepared) { | ||
throw new Error( | ||
'Unable to finish setup before `render()` was called. ' + | ||
|
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.
Why is
& { elevation?: number }
needed?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
elevation
prop is added to children, sinceunknown
type doesn't haveelevation
type, i explicitly added. I'm not entirely sure if this is optimal, but please let me know if you have better suggestion.material-ui/docs/data/material/components/app-bar/ElevateAppBar.tsx
Line 32 in 6019f2a
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.
I think we can have only the elevation prop:
As unknown is absorbed in intersections:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type:~:text=//%20In%20an%20intersection%20everything%20absorbs%20unknown
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.
fixed here 3ff9828