Skip to content

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

@jeffreymorlan

Description

@jeffreymorlan

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 febda00

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions