TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

1.8: type guard no longer narrows from {} to primitive

Open jeffreymorlan opened this issue 10 years ago • 1 comments

This works in 1.7:

var a: {};
if (typeof a === 'number') {
    var b: number = a;
}

but in the master branch, a is not narrowed and you get an error. This seems to have started with commit febda00f1b430761df7e0e90bbb99cf8c99e4653

jeffreymorlan avatar Dec 28 '15 20:12 jeffreymorlan

:clap: :clap: @weswigham

DanielRosenwasser avatar Jan 15 '16 00:01 DanielRosenwasser