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
Update tslib to support new __spreadArray helper #133
Conversation
@orta, CI for 14.x failed but I'm not sure why: https://github.com/microsoft/tslib/pull/133/checks?check_run_id=1393759257#step:4:35 |
export declare function __spreadArrays(...args: any[][]): any[]; | ||
export declare function __spreadArray(to: any[], from: any[]): any[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more correct:
export declare function __spreadArray(to: any[], from: any[]): any[]; | |
export declare function __spreadArray<T, U>(to: T[], from: ReadonlyArray<U>): Array<T | U>; |
Although this would be even more correct, it depends on TypeScript 4.0:
export declare function __spreadArray<T extends any[], U extends readonly any[]>(to: T, from: U): [...T, ...U];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types here are fairly simplistic. If we were going to add generics here we would want to add them to other functions as well, but that's out of scope for now.
Do note that |
Thanks! Got a local repro for the fail |
Great catch on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, and I've validated the CI works as expected.
I'll leave you to decide whether the generic change above is worth it here.
@DanielRosenwasser this will probably need to be published before we merge microsoft/TypeScript#41523 so anyone using our nightlies can get a working copy of tslib. |
Which version of TypeScript will start using |
@Finesse TypeScript is using |
- Since Typescript 4.2 some Helpers to transpile to 4.2 are deprecated/removed. This includes __spread and __spreadArrays microsoft/TypeScript#41523. - We heavily use the spread syntax in Dark Reader and thus need those helper functions. - Due the upgrade of 4.2, tslib was outdated and didn't had the new helper function `__spreadArray`. - After good hours of skimming trough the compiler and using the wrong commands to update tslib(default to 1.x). manually updating it to 2.1 which includes this new functions microsoft/tslib#133 https://github.com/microsoft/tslib/releases/tag/2.1.0 the API can be properly compiled again. - Resolves #My personal issues with the API.
- Since Typescript 4.2 some Helpers to transpile to 4.2 are deprecated/removed. This includes __spread and __spreadArrays microsoft/TypeScript#41523. - We heavily use the spread syntax in Dark Reader and thus need those helper functions. - Due the upgrade of 4.2, tslib was outdated and didn't had the new helper function `__spreadArray`. - After good hours of skimming trough the compiler and using the wrong commands to update tslib(default to 1.x). manually updating it to 2.1 which includes this new functions microsoft/tslib#133 https://github.com/microsoft/tslib/releases/tag/2.1.0 the API can be properly compiled again. - Resolves #My personal issues with the API. Note to myself: Now their are 2 versions installed `2.1.10` and `1.14.1` properly configuration setups should default to 2.1.10. But for sakes if I get into problems with this I hope I remember this note and don't waste some hours. Why `1.14.1`, I don't know. `npm --save-dev -E tslib` defaults to 1.14.1. It seems like an NPM bug `yarn add --dev -E tslib` gives the correct 2.1.10. Damn dependency hell =).
The version + features of typescript used to compile this lib means that tslib needs to be at version 2.0.0 minimum. Because `antvis/algorithm` doesn't specify an explicit version, it is not guaranteed that developers receive the necessary version. This causes the following error at import time: ``` ./node_modules/@antv/algorithm/es/gaddi.js Attempted import error: '__spreadArray' is not exported from 'tslib'. ``` You can see here all the other projects updating their tslib dependencies similarly in the references to this PR: microsoft/tslib#133 This relates to antvis/G6#2702 and antvis/G6#2713 it is likely necessary, but may not be sufficient, to fix those reported issues. There could be other `antvis` packages with the same issue.
This applies the same change from microsoft/TypeScript#41523. This also deprecates
__spread
and__spreadArrays
, as they have been subsumed by__spreadArray
. If we want to remove__spread
and__spreadArrays
, that would require a major version bump.