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

feat(rome_js_parser): Implement the decorator parsing via the option #4598

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

denbezrukov
Copy link
Contributor

@denbezrukov denbezrukov commented Jun 21, 2023

Summary

Close #4595

Expand JsFormalParameter, JsRestParameter, TsPropertyParameter, TsThisParameter with a decorator node:

JsFormalParameter =
        decorators: JsDecoratorList
	binding: AnyJsBindingPattern
	'?'?
	type_annotation: TsTypeAnnotation?
	initializer: JsInitializerClause?
JsRestParameter =
        decorators: JsDecoratorList
	'...'
	binding: AnyJsBindingPattern
	type_annotation: TsTypeAnnotation?

New syntax:

class A {
    method(@dec x, second, @dec third = 'default') {}
    method(@dec.fn() x, second, @dec.fn() third = 'default') {}
    method(@dec() x, second, @dec() third = 'default') {}
    static method(@dec x, second, @dec third = 'default') {}
    static method(@dec.fn() x, second, @dec.fn() third = 'default') {}
    static method(@dec() x, second, @dec() third = 'default') {}
    
    set val(@dec x) {}
    set val(@dec.fn() x) {}
    set val(@dec() x) {}
}

class A {
  constructor(@dec val,@dec2 private  v) {}
}

class C {
    constructor(@foo readonly x: number) {}
}
class CC {
    constructor(@foo @dec(arg) readonly x: number) {}
}
class CC {
    constructor(@foo @dec.method(arg) readonly x: number) {}
}
class CCC {
    constructor(@foo @dec.method(arg) private readonly x: number) {}
}

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 Jun 21, 2023

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 3d7e790
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/6495c29a4172220008894360

@github-actions github-actions bot added A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Tooling Area: our own build, development, and release tooling labels Jun 21, 2023
@github-actions
Copy link

github-actions bot commented Jun 21, 2023

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 48863 48863 0
Passed 47810 47810 0
Failed 1053 1053 0
Panics 0 0 0
Coverage 97.84% 97.84% 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 1764 ✅ ⏫ +1
Failed 4449 4448 ✅ ⏬ -1
Panics 0 0 0
Coverage 28.38% 28.40% +0.02%
🎉 Fixed (1):
noEmitHelpers2.symbols

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 13121 13121 0
Failed 4103 4103 0
Panics 0 0 0
Coverage 76.18% 76.18% 0.00%

@denbezrukov denbezrukov force-pushed the feat/parameter-decorator-parser branch 2 times, most recently from 0e5fb05 to 9ab7211 Compare June 23, 2023 08:17
@denbezrukov denbezrukov force-pushed the feat/parameter-decorator-parser branch from cfb082b to da874dc Compare June 23, 2023 15:36
@denbezrukov denbezrukov merged commit ff79022 into main Jun 23, 2023
@denbezrukov denbezrukov deleted the feat/parameter-decorator-parser branch June 23, 2023 19:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter A-Linter Area: linter 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.

Implement the decorator parsing via the option
2 participants