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
{{ message }}
Repository navigation
Apparent properties in union of primitive and object causes incorrect error #31668
$ ./node_modules/.bin/tsc --version
Version 3.5.1
$ ./node_modules/.bin/tsc --lib es2015 --strict ./repro.ts
repro.ts:5:6 - error TS2326: Types of property 'sub' are incompatible.
Type 'null' is not assignable to type '(() => string) | undefined'.
5 sign({ sub: null })
~~~~~~~~~~~~~
Found 1 error.
$ ./node_modules/.bin/tsc --version
Version 3.6.0-dev.20190530
$ ./node_modules/.bin/tsc --lib es2015 --strict ./repro.ts
repro.ts:5:6 - error TS2326: Types of property 'sub' are incompatible.
Type 'null' is not assignable to type '(() => string) | undefined'.
5 sign({ sub: null })
~~~~~~~~~~~~~
Found 1 error.
changed the title [-][3.5.1 Regression] String.prototype methods confusion when string|object[/-][+]Apparent properties in union of primitive and object causes incorrect error[/+]on May 31, 2019
Looks like the discriminating logic gets tripped up
Hm, I guess we probably shouldn't look at apparent types for discriminators when object is involved in the union (since we only want to discriminate against other real object types, not primitive apparent types).
Activity
[-][3.5.1 Regression] String.prototype methods confusion when string|object[/-][+]Apparent properties in union of primitive and object causes incorrect error[/+]RyanCavanaugh commentedon May 31, 2019
Wesley Wigham (@weswigham) reduced
Looks like the discriminating logic gets tripped up
weswigham commentedon May 31, 2019
Hm, I guess we probably shouldn't look at apparent types for discriminators when
objectis involved in the union (since we only want to discriminate against other real object types, not primitive apparent types).