Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_parser): EcmaScript @decorators #4252 #4392

Merged
merged 11 commits into from
Apr 26, 2023

Conversation

denbezrukov
Copy link
Contributor

@denbezrukov denbezrukov commented Apr 19, 2023

Summary

Implement decorators before export and export default.

ECMA spec page of the decorators:
https://arai-a.github.io/ecma262-compare/?pr=2417
https://github.com/tc39/proposal-decorators

The PR adds syntax:

@decorator
export class Foo { }

@decorator
export abstract class Foo { }

@decorator
export default class Foo { }

@decorator
export default abstract class Foo { }

Current syntax state of decorators:

@decorator
export class Foo { }

@first.field @second @(() => decorator)()
export class Bar {}

@before
export @after class Foo { }

@before
export abstract class Foo { }

@before
export @after abstract class Foo { }

@decorator
export default class Foo { }

@first.field @second @(() => decorator)()
export default class Bar {}

@before
export default @after class Foo { }

@before
export default abstract class Foo { }

@before
export default @after abstract class Foo { }

Test Plan

cargo test

Changelog

  • The PR requires a changelog line

Documentation

  • The PR requires documentation
  • I will create a new PR to update the documentation

@netlify
Copy link

netlify bot commented Apr 19, 2023

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 54f44f1
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/64492be3fb7e3a000733ffac

@github-actions github-actions bot added A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: our own build, development, and release tooling labels Apr 19, 2023
@denbezrukov denbezrukov changed the title Feature/export class decorators feat(rome_js_parser): EcmaScript @decorators #4252 Apr 19, 2023
@github-actions
Copy link

github-actions bot commented Apr 19, 2023

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 48863 48863 0
Passed 47796 47796 0
Failed 1067 1067 0
Panics 0 0 0
Coverage 97.82% 97.82% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6212 6212 0
Passed 1763 1763 0
Failed 4449 4449 0
Panics 0 0 0
Coverage 28.38% 28.38% 0.00%

ts/babel

Test result main count This PR count Difference
Total 639 639 0
Passed 573 573 0
Failed 66 66 0
Panics 0 0 0
Coverage 89.67% 89.67% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17224 17224 0
Passed 13087 13122 ✅ ⏫ +35
Failed 4137 4102 ✅ ⏬ -35
Panics 0 0 0
Coverage 75.98% 76.18% +0.20%
🎉 Fixed (35):
compiler/decoratorMetadataRestParameterWithImportedType.ts
compiler/emitHelpersWithLocalCollisions.ts
compiler/importHelpersES6.ts
compiler/importHelpersWithLocalCollisions.ts
conformance/decorators/class/decoratedClassExportsCommonJS1.ts
conformance/decorators/class/decoratedClassExportsCommonJS2.ts
conformance/decorators/class/decoratedClassExportsSystem1.ts
conformance/decorators/class/decoratedClassExportsSystem2.ts
conformance/decorators/class/decoratedClassFromExternalModule.ts
conformance/decorators/class/decoratorOnClass2.ts
conformance/es6/decorators/class/decoratorOnClass2.es6.ts
conformance/es6/decorators/class/decoratorOnClass3.es6.ts
conformance/es6/decorators/class/decoratorOnClass4.es6.ts
conformance/es6/decorators/class/decoratorOnClass6.es6.ts
conformance/es6/decorators/class/decoratorOnClass7.es6.ts
conformance/es6/decorators/class/decoratorOnClass8.es6.ts
conformance/es6/moduleExportsAmd/decoratedDefaultExportsGetExportedAmd.ts
conformance/es6/moduleExportsCommonjs/decoratedDefaultExportsGetExportedCommonjs.ts
conformance/es6/moduleExportsSystem/decoratedDefaultExportsGetExportedSystem.ts
conformance/es6/moduleExportsUmd/decoratedDefaultExportsGetExportedUmd.ts
conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-commentPreservation.ts
conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-commonjs-classNamespaceMerge.ts
conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-commonjs.ts
conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-setFunctionName.ts
conformance/externalModules/es6/es6modulekindWithES5Target.ts
conformance/externalModules/es6/es6modulekindWithES5Target11.ts
conformance/externalModules/es6/es6modulekindWithES5Target3.ts
conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts
conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts
conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts
projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/main.ts
projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/main.ts
projects/decoratorMetadata/emitDecoratorMetadataSystemJS/main.ts
projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/main.ts
projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/main.ts

@jpike88
Copy link

jpike88 commented Apr 20, 2023

awesome stuff, can't wait to turn on noUnusedVariables on my angular project!

@rcoedo
Copy link

rcoedo commented Apr 21, 2023

  1. Learns about Rome: 😄
  2. Finds out that decorators are not supported: 😩
  3. Finds out there was a kind soul actively working on the feature 1 hour ago: 😄

Thank you so much for the effort!

@denbezrukov denbezrukov requested a review from ematipico April 22, 2023 06:05
@ematipico
Copy link
Contributor

!bench_parser

@github-actions
Copy link

Parser Benchmark Results

group                                          main                                   pr
-----                                          ----                                   --
parser/big5-added.json/cached                  1.01    163.7±2.62µs   103.2 MB/sec    1.00    161.6±1.66µs   104.5 MB/sec
parser/big5-added.json/uncached                1.01    200.9±0.61µs    84.1 MB/sec    1.00    198.7±0.16µs    85.0 MB/sec
parser/canada.json/cached                      1.07    122.5±5.18ms    17.5 MB/sec    1.00    114.9±4.54ms    18.7 MB/sec
parser/canada.json/uncached                    1.08    119.5±4.03ms    18.0 MB/sec    1.00    110.8±4.10ms    19.4 MB/sec
parser/checker.ts/cached                       1.06    134.9±3.82ms    19.3 MB/sec    1.00    127.4±2.06ms    20.4 MB/sec
parser/checker.ts/uncached                     1.04    140.6±1.56ms    18.5 MB/sec    1.00    135.3±2.09ms    19.2 MB/sec
parser/compiler.js/cached                      1.00     75.9±2.27ms    13.8 MB/sec    1.02     77.3±1.42ms    13.5 MB/sec
parser/compiler.js/uncached                    1.00     77.9±1.48ms    13.5 MB/sec    1.03     79.8±1.06ms    13.1 MB/sec
parser/d3.min.js/cached                        1.05     46.3±1.33ms     5.7 MB/sec    1.00     44.1±1.24ms     5.9 MB/sec
parser/d3.min.js/uncached                      1.00     46.1±1.10ms     5.7 MB/sec    1.01     46.7±0.79ms     5.6 MB/sec
parser/db.json/cached                          1.00      4.5±0.06ms    40.6 MB/sec    1.00      4.5±0.05ms    40.6 MB/sec
parser/db.json/uncached                        1.00      5.1±0.02ms    35.8 MB/sec    1.00      5.1±0.02ms    35.9 MB/sec
parser/dojo.js/cached                          1.00      3.2±0.01ms    21.1 MB/sec    1.01      3.3±0.03ms    20.8 MB/sec
parser/dojo.js/uncached                        1.01      3.7±0.01ms    18.3 MB/sec    1.00      3.7±0.01ms    18.5 MB/sec
parser/eucjp.json/cached                       1.00    267.6±2.47µs   146.3 MB/sec    1.00    267.2±2.98µs   146.6 MB/sec
parser/eucjp.json/uncached                     1.00    312.1±0.30µs   125.5 MB/sec    1.00    311.7±0.63µs   125.7 MB/sec
parser/ios.d.ts/cached                         1.07    121.5±2.43ms    15.4 MB/sec    1.00    113.6±1.58ms    16.4 MB/sec
parser/ios.d.ts/uncached                       1.02    119.3±1.85ms    15.6 MB/sec    1.00    116.5±1.61ms    16.0 MB/sec
parser/jquery.min.js/cached                    1.00     10.9±0.14ms     7.6 MB/sec    1.01     11.0±0.20ms     7.5 MB/sec
parser/jquery.min.js/uncached                  1.00     11.6±0.07ms     7.2 MB/sec    1.00     11.6±0.14ms     7.1 MB/sec
parser/math.js/cached                          1.03     96.5±1.55ms     6.7 MB/sec    1.00     93.7±1.66ms     6.9 MB/sec
parser/math.js/uncached                        1.05     95.8±0.68ms     6.8 MB/sec    1.00     91.6±1.18ms     7.1 MB/sec
parser/package-lock.json/cached                1.00   1867.6±6.02µs    73.8 MB/sec    1.00  1867.1±20.49µs    73.8 MB/sec
parser/package-lock.json/uncached              1.01      2.1±0.01ms    66.4 MB/sec    1.00      2.1±0.01ms    67.0 MB/sec
parser/parser.ts/cached                        1.00      2.3±0.02ms    20.9 MB/sec    1.00      2.3±0.01ms    21.0 MB/sec
parser/parser.ts/uncached                      1.00      2.7±0.00ms    18.3 MB/sec    1.00      2.7±0.01ms    18.4 MB/sec
parser/pixi.min.js/cached                      1.01     58.0±1.72ms     7.6 MB/sec    1.00     57.2±1.88ms     7.7 MB/sec
parser/pixi.min.js/uncached                    1.04     59.8±0.94ms     7.3 MB/sec    1.00     57.3±1.28ms     7.7 MB/sec
parser/react-dom.production.min.js/cached      1.00     14.6±0.28ms     7.9 MB/sec    1.07     15.6±0.48ms     7.4 MB/sec
parser/react-dom.production.min.js/uncached    1.00     15.7±0.14ms     7.3 MB/sec    1.04     16.3±0.32ms     7.0 MB/sec
parser/react.production.min.js/cached          1.00    692.0±3.62µs     8.9 MB/sec    1.01   696.1±10.28µs     8.8 MB/sec
parser/react.production.min.js/uncached        1.00    805.9±1.05µs     7.6 MB/sec    1.00    805.1±1.50µs     7.6 MB/sec
parser/router.ts/cached                        1.01    907.4±7.53µs    35.2 MB/sec    1.00    902.0±7.30µs    35.4 MB/sec
parser/router.ts/uncached                      1.01   1095.3±1.83µs    29.1 MB/sec    1.00   1086.4±5.03µs    29.4 MB/sec
parser/tex-chtml-full.js/cached                1.03    127.5±1.84ms     7.1 MB/sec    1.00    123.2±2.03ms     7.4 MB/sec
parser/tex-chtml-full.js/uncached              1.02    127.7±1.49ms     7.1 MB/sec    1.00    124.9±1.48ms     7.3 MB/sec
parser/three.min.js/cached                     1.03     64.9±1.49ms     9.0 MB/sec    1.00     62.7±1.43ms     9.4 MB/sec
parser/three.min.js/uncached                   1.03     65.7±1.15ms     8.9 MB/sec    1.00     64.0±1.18ms     9.2 MB/sec
parser/typescript.js/cached                    1.04    538.8±9.74ms    17.6 MB/sec    1.00    519.4±7.52ms    18.3 MB/sec
parser/typescript.js/uncached                  1.05    559.7±7.16ms    17.0 MB/sec    1.00    532.5±4.68ms    17.8 MB/sec
parser/vue.global.prod.js/cached               1.00     18.3±0.57ms     6.6 MB/sec    1.05     19.2±0.58ms     6.3 MB/sec
parser/vue.global.prod.js/uncached             1.00     19.6±0.34ms     6.2 MB/sec    1.02     19.9±0.40ms     6.1 MB/sec

Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Looks good! I left a couple of nits.
Please update the changelog before merging the PR.

Feel free to merge the PR once everything is addressed.

@denbezrukov denbezrukov merged commit c1b73f6 into main Apr 26, 2023
@denbezrukov denbezrukov deleted the feature/export-class-decorators branch April 26, 2023 14:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: our own build, development, and release tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants