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
// I detect if F is `any` by checking if F extends `never`.// (F extends never ? true : false) produces `true|false` for `F = any`// and `false` or `never` for everything else.typeDecider<F>={prop: (Fextendsnever ? true : false)extendsfalse ? "isNotAny" : "isAny";};letfoo!: Decider<string>;letbar: Decider<any>=foo;letfooProp: "isNotAny"=foo.prop;letbarProp: "isAny"=bar.prop;
Expected behavior:
Either bar.prop should have the type "isAny"|"isNotAny" or foo should not be assignable to bar.
Actual behavior: foo is assignable to bar and bar.prop has the type "isAny" which is incompatible with foo.prop's "isNotAny".
TypeScript Version: 3.5.0-dev.20190507
Search Terms:
any, unsound, extends, never
Code
Expected behavior:
Either
bar.propshould have the type"isAny"|"isNotAny"orfooshould not be assignable tobar.Actual behavior:
foois assignable tobarandbar.prophas the type"isAny"which is incompatible withfoo.prop's"isNotAny".Playground Link: ; let bar: Decider = foo;
let fooProp: "isNotAny" = foo.prop;
let barProp: "isAny" = bar.prop;" rel="nofollow">link