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

Update to Typescript v5.5.0 #7878

Merged
merged 7 commits into from
Jun 25, 2024
Merged

Update to Typescript v5.5.0 #7878

merged 7 commits into from
Jun 25, 2024

Conversation

hotzenklotz
Copy link
Member

@hotzenklotz hotzenklotz commented Jun 12, 2024

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:

  • CI

ToDos

  • Switch to final release version

Issues:

  • None

(Please delete unneeded items, merge only when none are left open)

@hotzenklotz hotzenklotz self-assigned this Jun 12, 2024
@hotzenklotz hotzenklotz changed the title update to Typescript v5.5.0 Update to Typescript v5.5.0 Jun 24, 2024
@hotzenklotz hotzenklotz marked this pull request as ready for review June 24, 2024 13:59
Copy link
Member

@philippotto philippotto left a 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];
Copy link
Member

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

Copy link
Member Author

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 ... | { ...; }>'.```

Copy link
Member

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)

Copy link
Member Author

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

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

🎉

@hotzenklotz hotzenklotz enabled auto-merge (squash) June 25, 2024 08:51
@hotzenklotz hotzenklotz merged commit 4d10869 into master Jun 25, 2024
2 checks passed
@hotzenklotz hotzenklotz deleted the typescript-v5.5.0 branch June 25, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants