Skip to content

Intersection of type parameter and undefined is not never in 4.9Β #51041

Closed
@dragomirtitian

Description

@dragomirtitian

Bug Report

πŸ”Ž Search Terms

intersection never

πŸ•— Version & Regression Information

  • This changed between versions 4.9.0-dev.20220914 and 4.9.0-dev.20220915

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type AB = "A" | "B"

function x<T_AB extends AB>() {
    let r2: never = null! as T_AB & undefined

} 

πŸ™ Actual behavior

The assignment of r2 fails with Type 'T_AB & undefined' is not assignable to type 'never'.. Since T_AB does not contain undefined in its constraint, the intersection should reduce to never (as it did in 4.8)

πŸ™‚ Expected behavior

The assignment should succeed.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions