Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type AAndB = {
- a: string;
- b: string;
- };
- type Neither = {
- someOtherProp: string;
- };
- type Props = AAndB | Neither;
- // This will throw a typescript compiler warning, as a is present without b
- const example: Props = {
- a: 'something'
- }
- // These will pass the typescript compiler
- const example2: Props = {
- a: 'something',
- b: 'something else',
- };
- const example3: Props = {
- someOtherProp: 'some other prop',
- };
Add Comment
Please, Sign In to add comment