-
Notifications
You must be signed in to change notification settings - Fork 22
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 to Typescript v5.5.0 #7878
Conversation
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.
thanks for the upgrade! great to see that lots if ignores could be removed 🎉
only see my one comment about array spreads.
@@ -181,5 +178,5 @@ export default function compactToggleActions( | |||
...exceptions.map((tree) => updateTreeVisibility(tree)), | |||
]; | |||
const finalToggleActions = shouldUseToggleGroup ? compactedToggleActions : toggleActions; | |||
return remainingActions.concat(finalToggleActions); | |||
return [...remainingActions, ...finalToggleActions]; |
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.
I'd be careful with array spreads due to performance. Since there might be lots of update actions here, I'd stick to concat.
small microbenchmark in chrome:
console.time("a")
res = arr.concat(arr)
console.timeEnd("a")
console.time("a")
res = [...arr, ...arr]
console.timeEnd("a")
a: 0.332763671875 ms
a: 13.9931640625 ms
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.
arghh... 😱
concat drives TS into a rage:
Overload 1 of 2, '(...items: ConcatArray<UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 23 more ... | { ...; }>[]): (UpdateTreeUpdateAction | ... 25 more ... | { ...; })[]', gave the following error.
Argument of type '({ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; } | { readonly name: "updateTreeGroupVisibility"; readonly value: { readonly treeGroupId: number | ... 1 more ... | undefined; readonly isVisible: boolean; }; })[]' is not assignable to parameter of type 'ConcatArray<UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 23 more ... | { ...; }>'.
The types returned by 'slice(...)' are incompatible between these types.
Type '({ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; } | { readonly name: "updateTreeGroupVisibility"; readonly value: { readonly treeGroupId: number | ... 1 more ... | undefined; readonly isVisible: boolean; }; })[]' is not assignable to type '(UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 23 more ... | { ...; })[]'.
Type '{ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; } | { readonly name: "updateTreeGroupVisibility"; readonly value: { readonly treeGroupId: number | ... 1 more ... | undefined; readonly isVisible: boolean; }; }' is not assignable to type 'UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 23 more ... | { ...; }'.
Type '{ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; }' is not assignable to type 'UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 23 more ... | { ...; }'.
Type '{ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; }' is not assignable to type '{ name: "mergeAgglomerate"; value: { agglomerateId1: number; agglomerateId2: number; mag: Vector3; segmentId1: number | undefined; segmentId2: number | undefined; segmentPosition1?: Vector3 | undefined; segmentPosition2?: Vector3 | undefined; }; }'.
Types of property 'name' are incompatible.
Type '"updateTreeVisibility"' is not assignable to type '"mergeAgglomerate"'.
Overload 2 of 2, '(...items: (UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 24 more ... | ConcatArray<...>)[]): (UpdateTreeUpdateAction | ... 25 more ... | { ...; })[]', gave the following error.
Argument of type '({ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; } | { readonly name: "updateTreeGroupVisibility"; readonly value: { readonly treeGroupId: number | ... 1 more ... | undefined; readonly isVisible: boolean; }; })[]' is not assignable to parameter of type 'UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 24 more ... | ConcatArray<...>'.
Type '({ readonly name: "updateTreeVisibility"; readonly value: { readonly treeId: number; readonly isVisible: boolean; }; } | { readonly name: "updateTreeGroupVisibility"; readonly value: { readonly treeGroupId: number | ... 1 more ... | undefined; readonly isVisible: boolean; }; })[]' is not assignable to type 'ConcatArray<UpdateTreeUpdateAction | { readonly name: "deleteTree"; readonly value: { readonly id: number; }; } | { readonly name: "mergeTree"; readonly value: { readonly sourceId: number; readonly targetId: number; }; } | ... 23 more ... | { ...; }>'.```
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.
does sth like this work? return (remainingActions as UpdateAction[]).concat(finalToggleActions);
I tested this in a playground with this:
const arr = [1, 2, 3]
const arr2 = [true, false];
(arr as Array<number | boolean>).concat(arr2)
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.
Yes, more or less. see PR feedback commit
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.
🎉
PR ugrades to the latest Typescript version 5.5.0 which includes some useful, new features, including inferred type predicates and control flow narrowing for constant indexed accesses.
The TS team claims up to 20% performance improvements for the TS language server integration in code editors.
More on the full blog post.
The final release is expected on 2024-06-18.
Steps to test:
ToDos
Issues:
(Please delete unneeded items, merge only when none are left open)