-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[material-ui] Change React.ReactElement<any> to React.ReactElement<unknown> #43402
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
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()), | ||
|
||
| }), | ||
| ), | ||
| ); | ||
|
|
@@ -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
elevationprop is added to children, sinceunknowntype doesn't haveelevationtype, 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