forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[typescript-to-proptypes] Support using
Omit
on types with conditio…
…nal properties (mui#41033)
- Loading branch information
1 parent
fb3dfb0
commit c5b4eba
Showing
3 changed files
with
83 additions
and
29 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
5 changes: 5 additions & 0 deletions
5
packages/typescript-to-proptypes/test/omit-conditional/input.d.ts
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,5 @@ | ||
type TextFieldProps<A extends boolean> = A extends true ? { testProp: string } : { testProp: boolean } | ||
|
||
type Props<A extends boolean = false> = Omit<TextFieldProps<A>, 'b'> | ||
|
||
export function Foo<A extends boolean = false>(props: Props<A>): JSX.Element; |
3 changes: 3 additions & 0 deletions
3
packages/typescript-to-proptypes/test/omit-conditional/output.js
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,3 @@ | ||
Foo.propTypes = { | ||
testProp: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired, | ||
}; |