Skip to content

CFA failure with fallthrough clauses in switch statements #23818

Open
@falsandtru

Description

@falsandtru

TypeScript Version: master

Search Terms:

Code

declare const o: { c?: 1; };
switch (0) {
  case 0:
    break;
  case o.c && o.c.valueOf():
  case o.c && o.c.valueOf():
    break;
}

Expected behavior:

pass

Actual behavior:

$ node built/local/tsc.js index.ts --strictNullChecks
index.ts:5:15 - error TS2532: Object is possibly 'undefined'.

5   case o.c && o.c.valueOf():
                ~~~

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions