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

FR: More brilliant Type inference #20249

Closed
Jack-Works opened this issue Nov 24, 2017 · 3 comments
Closed

FR: More brilliant Type inference #20249

Jack-Works opened this issue Nov 24, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@Jack-Works
Copy link
Contributor

TypeScript Version: 2.6.1

Code

type Response200 = { url: string } & { response: Response & { status: 200 } }
type Response201 = { data: any[] } & { response: Response & { status: 201 } }
declare function request(): Response200 | Response201
const result = request()
switch (result.response.status) {
    case 200:
	result.response.status // <- (property) status: number & 200
	// Expected status: 200

	result // type = Response200 | Response201, Expected Response200
    break
}
@ORESoftware
Copy link

Can you add more of a description of the problem?

@DanielRosenwasser
Copy link
Member

Partial duplicate of #18758 (also see #20127), though I am surprised we don't collapse number & 200 to 200.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 27, 2017
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants