Skip to content

Possible type inference regression (from v3.2.4 onwards) #29914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tlaitinen opened this issue Feb 14, 2019 · 3 comments
Closed

Possible type inference regression (from v3.2.4 onwards) #29914

tlaitinen opened this issue Feb 14, 2019 · 3 comments
Assignees
Labels
Fixed A PR has been merged for this issue Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros

Comments

@tlaitinen
Copy link

tlaitinen commented Feb 14, 2019

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms: type inference regression

Code

export function f<A>() {
  let a:undefined extends A | undefined ? A | undefined : undefined = undefined;
  return a;
}

Expected behavior: No type error. TypeScript compiler version 3.2.2 gives no error.

Actual behavior:
Starting version 3.2.4 TypeScript compiler gives the following type error:

$ tsc --strict error.ts
error.ts:2:7 - error TS2322: Type 'undefined' is not assignable to type 'undefined extends A | undefined ? A | undefined : undefined'.

2   let a:undefined extends A | undefined ? A | undefined : undefined = undefined;

Playground Link: could not reproduce in TypeScript Playground.

Related Issues:

@jack-williams
Copy link
Collaborator

Looks related to #29662

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 19, 2019
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 26, 2022

Looks to be fixed in 4.3.

export function f<A>() {
    let a: undefined extends A | undefined ? A | undefined : undefined = undefined;
    return a;
}

@typescript-bot typescript-bot added the Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros label Aug 26, 2022
@typescript-bot
Copy link
Collaborator

👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.


Comment by @DanielRosenwasser

👍 Compiled

Historical Information
Version Reproduction Outputs
4.3.2, 4.4.2, 4.5.2, 4.6.2, 4.7.2

👍 Compiled

@DanielRosenwasser DanielRosenwasser added Fixed A PR has been merged for this issue and removed Needs Investigation This issue needs a team member to investigate its status. labels Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed A PR has been merged for this issue Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros
Projects
None yet
Development

No branches or pull requests

6 participants