From a040bd8fc70a0cc1b6c54b93489107da31a56fc1 Mon Sep 17 00:00:00 2001 From: Soonil Hong Date: Sun, 12 Jan 2025 18:48:50 -0500 Subject: [PATCH] Add legality update on Special Static Names in ES2022 --- .../documentation/copy/en/handbook-v2/Classes.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/documentation/copy/en/handbook-v2/Classes.md b/packages/documentation/copy/en/handbook-v2/Classes.md index da70ad9bd633..7cfe168cc7c0 100644 --- a/packages/documentation/copy/en/handbook-v2/Classes.md +++ b/packages/documentation/copy/en/handbook-v2/Classes.md @@ -885,6 +885,22 @@ class S { } ``` +> This is legal starting ES2022. Note the difference between the tranpiled JavaScript files targetting ES2021 and ES2022. + +```js +// javascript output targetting ES2021 +class S { +} +S.name = "S!"; +``` + +```js +// javascript output targetting ES2022 +class S { + static name = "S!"; +} +``` + ### Why No Static Classes? TypeScript (and JavaScript) don't have a construct called `static class` the same way as, for example, C# does.