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 inference doesn't work for switch-case of 'constructor' property #31961

Closed
Sgt-Nukem opened this issue Jun 18, 2019 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@Sgt-Nukem
Copy link

Search Terms

constructor type inference switch case

Suggestion

Let a switch (XXX.constructor) correctly infer types in case blocks.

Example

c.f. the following snippet (the Router is the Angular Router btw)

image

In case NavigationError: block it should be clear that event is indeed a NavigationError instance and I would like to get IntelliSense for that.

As NavigationError has an error property (c.f. following image) I would expect to get that shown in the IntelliSense tooltip in the image above -- but I get console.error() only!

image

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 25, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@murbanowicz
Copy link

As #23274 does not fix the case for switch I think this one should be re-opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants