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

castArray error #985

Closed
librehome opened this issue Feb 14, 2021 · 2 comments
Closed

castArray error #985

librehome opened this issue Feb 14, 2021 · 2 comments

Comments

@librehome
Copy link

The castArray won't compile against later versions (e.g. 4.1.3) of TypeScript.
I made the changes in utils.ts:

export function castArray<T>(value: T | readonly T[]): readonly T[] {
    if (Array.isArray(value)) {
        return value;
    } else {
        const v: T = value as any;
        return [v];
    }
}
@Perryvw Perryvw added bug and removed bug labels Feb 14, 2021
@Perryvw
Copy link
Member

Perryvw commented Feb 14, 2021

This is a TypeScript bug: microsoft/TypeScript#41984 We will not be changing castArray as it is correct. Maybe we can set an upper limit to the TypeScript version. Seems like TS is planning to deliver their fix in 4.2.0, highest working version should be 4.1.2

@librehome
Copy link
Author

Yes, I agree it is a TS bug. I reported because the playground is using TS 4.1.3 while I couldn't compile.
Let's wait for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants