Skip to content
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

Type Parameter Union Regression #42932

Closed
osyrisrblx opened this issue Feb 24, 2021 · 0 comments Β· Fixed by #42943
Closed

Type Parameter Union Regression #42932

osyrisrblx opened this issue Feb 24, 2021 · 0 comments Β· Fixed by #42943
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@osyrisrblx
Copy link

osyrisrblx commented Feb 24, 2021

Bug Report

πŸ”Ž Search Terms

type parameter union regression

πŸ•— Version & Regression Information

  • This changed between versions 4.1.5 and 4.2-beta

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

enum Enum {
	A,
	B,
	C,
}

interface Interface<T extends Enum> {
	type: T;
}

function foo<T extends Enum>(x: Interface<T>) { }

// this no longer works as of 4.2
function bar(x: Interface<Enum.A | Enum.B> | Interface<Enum.C>) {
	foo(x);
}

// but this works?
function baz(x: Interface<0 | 1> | Interface<2>) {
	foo(x);
}

πŸ™ Actual behavior

Emits an error.

πŸ™‚ Expected behavior

Should not error.

@ahejlsberg ahejlsberg self-assigned this Feb 24, 2021
@ahejlsberg ahejlsberg added the Bug A bug in TypeScript label Feb 24, 2021
@ahejlsberg ahejlsberg added this to the TypeScript 4.2.2 milestone Feb 24, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants