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
interfaceX{x: string}interfaceY{y: number}interfaceZ{z?: boolean}typeXY=X&Y;constxy: XY={x: 'x',y: 10};constz1: Z=xy;// (1) compiles without any errorsconstz2: Z=xyasPick<XY,keyofXY>;// (2) produces error: Type 'Pick<X & Y, "x" | "y">' has no properties in common with type 'Z'.
Expected behavior:
(1) should produce an error similar to (2) because there are no common properties for XY and Z types.
I looked at the code and I think the exclusion of intersection sources is a side-effect of the original implementation, which only worked on object types. But it's trivial to allow intersections as source types.
I didn't see any new errors on the user tests, and on Definitely Typed, only in react-native-sortable-list and react-native-swiper, where we now detect the assignment of a branded number to an object type. The branded number came from a mapped type, so this is a subtle bug, and a very good catch.
Activity
sandersn commentedon Aug 24, 2018
I looked at the code and I think the exclusion of intersection sources is a side-effect of the original implementation, which only worked on object types. But it's trivial to allow intersections as source types.
I didn't see any new errors on the user tests, and on Definitely Typed, only in react-native-sortable-list and react-native-swiper, where we now detect the assignment of a branded number to an object type. The branded number came from a mapped type, so this is a subtle bug, and a very good catch.
I'll make a test and send out a PR.