Skip to content

Weaken type checks based on CFA with assertion conditions #35567

Closed as not planned
@falsandtru

Description

@falsandtru

Too strict for tests.

cc @ahejlsberg

TypeScript Version: 3.7.x-dev.20191207

Search Terms:

Code

declare function assert(value: any): asserts value;
declare const set: Set<0>;

assert(set.size === 0);
set.add(0);
assert(set.size === 1);

Expected behavior:
pass
Actual behavior:
This condition will always return 'false' since the types '0' and '1' have no overlap.(2367)
Playground Link: http://www.typescriptlang.org/play/index.html?ssl=1&ssc=1&pln=6&pc=24#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXygGdCQYMAKANygmRAC4DUBPASkaJLMPmtpADcAKFCRYCMHkIZ4JDIwDKIDAB4ADAD5hQzqQpyAdISwAvBAF5L8Na2GGowYORvDdZcoeNn4l8-ACMtkA

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions