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

Incorrect 'never' type inference in TypeScript 2.6 #20952

Closed
sharwell opened this issue Dec 31, 2017 · 3 comments
Closed

Incorrect 'never' type inference in TypeScript 2.6 #20952

sharwell opened this issue Dec 31, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@sharwell
Copy link
Member

sharwell commented Dec 31, 2017

TypeScript Version: 2.6.2

Code

https://github.com/sharwell/antlr4ts/blob/c9a8ef86fbdfc7f027916b5b281dac322495ca55/src/atn/LL1Analyzer.ts#L251

Expected behavior:

When the line is reached, t has the type Transition.

Actual behavior:

When the line is reached, t has the inferred type never. We are forced to work around the issue by explicitly casting and reassigning the variable.

@HerringtonDarkholme
Copy link
Contributor

HerringtonDarkholme commented Jan 2, 2018

Please patiently await TS2.7. #19671

It is probably because your concrete class have structurally identical type with your abstract class.

https://github.com/sharwell/antlr4ts/blob/c9a8ef86fbdfc7f027916b5b281dac322495ca55/src/atn/WildcardTransition.ts#L13

@the8thavatar
Copy link

I also see this problem from TypeScript v2.5.2 onwards where it was ok in 2.4.1..
var existingSymbol: SASymbol,...
nodes = canvas.getNodes();
for (i = 0; i < nodes.length; i++) {
existingSymbol = nodes[i] as SASymbol;
if ((existingSymbol.isSASymbol || existingSymbol instanceof PlaceableText
|| existingSymbol instanceof DiagramNode || existingSymbol instanceof ShapeNode || existingSymbol instanceof SvgNode
)
...)
It reports existingSymbol to be type never from this point: existingSymbol instanceof ShapeNode
.. but I can delete the preceding cases and it becomes the expected SASymbol type again.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 2, 2018
@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 Jul 3, 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