-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use exact children type to allow React type augmentation
- Loading branch information
1 parent
95e41fd
commit b3a314d
Showing
9 changed files
with
34 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/mui-material/test/typescript/reactAugmentation/children.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import Autocomplete from '@mui/material/Autocomplete'; | ||
import TextField from '@mui/material/TextField'; | ||
|
||
type AugmentedChildren = React.ReactNode | Record<string, unknown>; | ||
|
||
// Update React's children prop type | ||
declare module 'react' { | ||
interface HTMLAttributes<T> { | ||
children?: AugmentedChildren | Iterable<AugmentedChildren>; | ||
} | ||
} | ||
|
||
// Rendering a TextField for the Autocomplete should work | ||
<Autocomplete options={[{ label: 'test' }]} renderInput={(params) => <TextField {...params} />} />; |
7 changes: 7 additions & 0 deletions
7
packages/mui-material/test/typescript/reactAugmentation/children.tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"skipLibCheck": true | ||
}, | ||
"extends": "../../../../../tsconfig", | ||
"files": ["children.spec.tsx"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig", | ||
"include": ["src/**/*", "test/**/*"], | ||
"exclude": ["test/typescript/moduleAugmentation", "src/types/OverridableComponentAugmentation.ts"] | ||
"exclude": [ | ||
"test/typescript/moduleAugmentation", | ||
"test/typescript/reactAugmentation", | ||
"src/types/OverridableComponentAugmentation.ts" | ||
] | ||
} |