Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jun 23, 2017

If this is an any[] then any value that's possibly an emptyArray will also be considered an any[].
This should actually be a ReadonlyArray<never> but see #16716.

namespace ts {
export const scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
export const emptyArray: any[] = [];
export const emptyArray: never[] = [] as never[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need the casting?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise I get undefined[] is not assignable to never[] error. May be related to #16651.

@ghost
Copy link
Author

ghost commented Jul 6, 2017

I made this part of #16836 since I needed to use emptyArray in the compiler too.

@ghost ghost closed this Jul 6, 2017
@ghost ghost deleted the emptyArray branch July 6, 2017 14:17
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants