Skip to content

Control flow analysis: T|T[] case, Array.isArray and else case #8935

Closed
@Strate

Description

@Strate

TypeScript Version:

1.9.0-dev (nightly)

Code

// A self-contained demonstration of the problem follows...
function <T>(arg: T|T[]) {
  if (Array.isArray(arg)) {
    // arg expected to be T[] here, and it has type T[] (works as expected)
  } else {
    // arg expected to be T here, but it is has type T|T[] (unexpected behaviour)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions