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

ts.NodeArray<T> no longer mixes well with Array.isArray() #19886

Closed
SlurpTheo opened this issue Nov 9, 2017 · 4 comments
Closed

ts.NodeArray<T> no longer mixes well with Array.isArray() #19886

SlurpTheo opened this issue Nov 9, 2017 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@SlurpTheo
Copy link

SlurpTheo commented Nov 9, 2017

TypeScript Version: 2.6.1

Code

const arr: ts.NodeArray<ts.VariableDeclaration> = node as ts.NodeArray<ts.VariableDeclaration>;
if (Array.isArray(arr)) {
	const x = arr;
	const y = x[0].getText;	// getText() no longer in IntelliSense
}

Expected behavior:
Control-flow analysis used to know that x was an array of ts.VariableDeclaration.

Actual behavior:
Now it's all mixed-up (intersectioned with any[]).

image

@ghost
Copy link

ghost commented Nov 10, 2017

Looks like a duplicate of #17002. (NodeArray inherits from ReadonlyArray)

@ghost ghost added the Duplicate An existing issue was already created label Nov 10, 2017
@SlurpTheo
Copy link
Author

@andy-ms It does look very similar only my code was not an issue in 2.4.2 (#17002 says it was happening in 2.4.1).

@ghost
Copy link

ghost commented Nov 10, 2017

Oh, that's because ts.NodeArray was mutable back then.

@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

2 participants