-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 TypeScript target to es2022
for updated types like Error.prototype.cause
#24913
Labels
A-Developer-Experience
A-Testing
Testing, code coverage, etc.
T-Task
Tasks for the team like planning
Comments
MadLittleMods
added
T-Task
Tasks for the team like planning
A-Testing
Testing, code coverage, etc.
A-Developer-Experience
labels
Mar 23, 2023
MadLittleMods
changed the title
Update TypeScript target to
Update TypeScript target to Mar 23, 2023
es2022
es2022
for updated types like Error.prototype.cause
Looking at the compat table at https://compat-table.github.io/compat-table/es2016plus, I can't see any reason not to do this: all the supported platforms for Element-Web, and the recent nodejs versions supported by matrix-js-sdk, are fine all the way up to ES2024, with a yellow flag for "Regexp Matches Indices", which I don't think is relevant here. |
richvdh
added a commit
to matrix-org/matrix-js-sdk
that referenced
this issue
Jun 21, 2024
I want to be able to use `WeakRef`, and per element-hq/element-web#24913 (comment), I believe this should be safe.
github-merge-queue bot
pushed a commit
to matrix-org/matrix-js-sdk
that referenced
this issue
Jun 21, 2024
* Bump ES target version to ES2022 I want to be able to use `WeakRef`, and per element-hq/element-web#24913 (comment), I believe this should be safe. * room.ts: Fix initialisation order It seems that ES2022 causes typescript to change the initialization order of regular properties vs parameter properties (microsoft/TypeScript#45995), so we need to rearrange the initializations to avoid an error. In practice, it might be fine because we have enabled `babel-plugin-transform-class-properties`, which moves the initialization back after the parameter property, but we shoudn't rely on that, and anyway it upsets the linter.
github-merge-queue bot
pushed a commit
to matrix-org/matrix-js-sdk
that referenced
this issue
Jun 21, 2024
* Bump ES target version to ES2022 I want to be able to use `WeakRef`, and per element-hq/element-web#24913 (comment), I believe this should be safe. * room.ts: Fix initialisation order It seems that ES2022 causes typescript to change the initialization order of regular properties vs parameter properties (microsoft/TypeScript#45995), so we need to rearrange the initializations to avoid an error. In practice, it might be fine because we have enabled `babel-plugin-transform-class-properties`, which moves the initialization back after the parameter property, but we shoudn't rely on that, and anyway it upsets the linter.
github-merge-queue bot
pushed a commit
to matrix-org/matrix-js-sdk
that referenced
this issue
Jun 21, 2024
* Bump ES target version to ES2022 I want to be able to use `WeakRef`, and per element-hq/element-web#24913 (comment), I believe this should be safe. * room.ts: Fix initialisation order It seems that ES2022 causes typescript to change the initialization order of regular properties vs parameter properties (microsoft/TypeScript#45995), so we need to rearrange the initializations to avoid an error. In practice, it might be fine because we have enabled `babel-plugin-transform-class-properties`, which moves the initialization back after the parameter property, but we shoudn't rely on that, and anyway it upsets the linter.
This was referenced Aug 1, 2024
Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Developer-Experience
A-Testing
Testing, code coverage, etc.
T-Task
Tasks for the team like planning
Currently, we define the TypeScript target as
es2016
.Is there a specific reason, we're staying behind at that version?
Why would you like to update?
I would like to update to
es2022
in order getcause
property onError
. Introduced in TypeScript 4.6, see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-6.html#--target-es2022This is spawning from matrix-org/matrix-react-sdk#10432 (comment) where I might have a usage for the
cause
property andError
constructor usage.MDN reference for
cause
property onError
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/causeRelated TypeScript issues:
Error.prototype.cause
has inaccurate value type microsoft/TypeScript#48098Possible alternative
For my specific case, we can probably just override what we want in
src/@types/global.d.ts#L189-L196
Based off of TypeScript source,
src/lib/es2022.error.d.ts
The text was updated successfully, but these errors were encountered: