You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I'm having a type that allows the user to provide a type + resourceId + size (all required).
Once the user also passes a overrideURI parameter, the type + resourceId + size props become optional.
This works out great, but once I start using Omit<> on that type to remove a property that is contained in both types I get an error.
exporttypeWithOptional<T,TPropsextendskeyofT>=Partial<Pick<T,TProps>>&Omit<T,TProps>;exporttypeWithRequired<T,TPropsextendskeyofT>=Required<Pick<T,TProps>>&Omit<T,TProps>;interfaceCuventImagePropsBase{resourceId: string;type: "profile"|"group";size?: "full"|"thumbnail";style: Record<string,unknown>;}exporttypeCuventImageProps=|({overrideURI: string;}&WithOptional<CuventImagePropsBase,"type"|"resourceId"|"size">)|({overrideURI?: undefined;}&WithRequired<CuventImagePropsBase,"type"|"resourceId"|"size">);constCuventImage=(props: CuventImageProps): React.ReactElement|null=>null;interfaceAppProps{// THIS OMIT CAUSES THE PROBLEMS BELOWimageProps: Omit<CuventImageProps,'style'>;}functionApp(props: AppProps){// Types of property 'overrideURI' are incompatible.// Type 'string' is not assignable to type 'undefined'.return<CuventImage{...props.imageProps}/>}
🙁 Actual behavior
The Omit<> call causes the TS union to be flattened incorrectly and makes the overrideURI parameter behave incorrectly.
🙂 Expected behavior
I expect it to behave exactly like without the Omit<>, just the style prop (prop that I omitted) should be missing.
The text was updated successfully, but these errors were encountered:
Bug Report
Hi!
I'm having a type that allows the user to provide a
type
+resourceId
+size
(all required).Once the user also passes a
overrideURI
parameter, thetype
+resourceId
+size
props become optional.This works out great, but once I start using
Omit<>
on that type to remove a property that is contained in both types I get an error.Here's a TS playground with a minimal reproducable sample: www.typescriptlang.org/play?.......
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The
Omit<>
call causes the TS union to be flattened incorrectly and makes theoverrideURI
parameter behave incorrectly.🙂 Expected behavior
I expect it to behave exactly like without the
Omit<>
, just thestyle
prop (prop that I omitted) should be missing.The text was updated successfully, but these errors were encountered: