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
interfaceA{type: 'A';inner: {a: boolean,};detail: string;}interfaceB{type: 'b';inner: {b: boolean,};detail: string;}typeCombined=A|B;// Broken - typescript does not raise an error, despite the mismatch between type 'A' and inner 'b'typeDescriptionBroken=Pick<Combined,'type'|'inner'>;letobj: DescriptionBroken={type: 'A',inner: {b: true}};// OK - typescript raises an error.typeDescriptionOk=Pick<A,'type'|'inner'>|Pick<B,'type'|'inner'>;letobjOk: DescriptionOk={type: 'A',inner: {b: true}};
Expected behavior:
The let obj line under the // Broken comment should raise an error, but does not.
Actual behavior:
The let obj line under the // Broken comment does not raise an error, presumably due to a disassociation between the 'type' and 'inner' elements.
The documentation for pick need to make that really, really clear. That is an extremely odd implementation detail. But, ok, closing this issue. Thanks for the link.
TypeScript Version: 3.7.0-dev.20190928
Search Terms: Pick, union bug, pick union bug
Code
Expected behavior:
The
let obj
line under the// Broken
comment should raise an error, but does not.Actual behavior:
The
let obj
line under the// Broken
comment does not raise an error, presumably due to a disassociation between the 'type' and 'inner' elements.Playground Link: https://www.typescriptlang.org/play/?ts=Nightly#code/JYOwLgpgTgZghgYwgAgILIN4ChnLATwAcIAuZAclXIG4dlQRoztdc4yAjAey4BsI4IADR0AvrVwATCGDjBeZAM5gooAOa1RWLKEixEKAEKY6BYmXIcadBkxOtkHTj36CRucXWmz5Sles1tMxQAYS4AWw5QCElkAF40ZAAfZENaLAB6DNSoLgBrCBBkAFo8IghFBFVCMGRJLgrkEC5aqDlFFEFkaFyoITqKwmBIPAALFHDgRXC4MARRxxkAdwhCsuIKKmRBWNsoCissYOQAEQqq4BrgLhBDXIKihIAFYAQ8gB4wyOjJfvJg8jJCh7cgAPlo-FqXA4ACsyGdKtUwNdbvc1gkMMELFR+ntmE48FAAK4QUSeTLZADyAGkSutzkjkG0po0uj0uFAAHRHcqnBmXZE3Sl5eLIF5vd6oP4AoHkEGgoHij6GaXlQEpOUgRhQMEQmTIaEw4Xw-lXIUijFYzbkXFauwYAkqElk6hAA
Related Issues: I found a number relating to Pick, but none with such a clean example or this exact issue. Maybe #33568?
The text was updated successfully, but these errors were encountered: