Skip to content

Commit

Permalink
feat(es/parser): Enable ergonomic brand checks for TypeScript (#2562)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 28, 2021
1 parent 303cecb commit 7b4af43
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ecmascript/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_parser"
repository = "https://github.com/swc-project/swc.git"
version = "0.76.0"
version = "0.76.1"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion ecmascript/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl Syntax {
Syntax::Es(EsConfig {
private_in_object, ..
}) => private_in_object,
_ => false,
Syntax::Typescript(_) => true,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ class MyClass {
constructor() {
this.#b = "test";
}

method() {
return #a in this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "Script",
"span": {
"start": 0,
"end": 98,
"end": 147,
"ctxt": 0
},
"body": [
Expand All @@ -21,7 +21,7 @@
"declare": false,
"span": {
"start": 0,
"end": 98,
"end": 147,
"ctxt": 0
},
"decorators": [],
Expand Down Expand Up @@ -220,6 +220,96 @@
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassMethod",
"span": {
"start": 102,
"end": 145,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 102,
"end": 108,
"ctxt": 0
},
"value": "method",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 102,
"end": 145,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 111,
"end": 145,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 121,
"end": 139,
"ctxt": 0
},
"argument": {
"type": "BinaryExpression",
"span": {
"start": 128,
"end": 138,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "PrivateName",
"span": {
"start": 128,
"end": 130,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 129,
"end": 130,
"ctxt": 0
},
"value": "a",
"optional": false
}
},
"right": {
"type": "ThisExpression",
"span": {
"start": 134,
"end": 138,
"ctxt": 0
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
Expand Down

2 comments on commit 7b4af43

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 7b4af43 Previous: 303cecb Ratio
base_tr_fixer 35100 ns/iter (± 3734) 43554 ns/iter (± 8152) 0.81
base_tr_resolver_and_hygiene 194784 ns/iter (± 38360) 257312 ns/iter (± 76314) 0.76
codegen_es2015 71218 ns/iter (± 8579) 86658 ns/iter (± 20852) 0.82
codegen_es2016 70323 ns/iter (± 9763) 86551 ns/iter (± 14508) 0.81
codegen_es2017 70639 ns/iter (± 8747) 81721 ns/iter (± 15011) 0.86
codegen_es2018 71410 ns/iter (± 7352) 86015 ns/iter (± 14978) 0.83
codegen_es2019 70733 ns/iter (± 6674) 86975 ns/iter (± 25715) 0.81
codegen_es2020 70334 ns/iter (± 4786) 84965 ns/iter (± 13748) 0.83
codegen_es3 74237 ns/iter (± 15630) 82907 ns/iter (± 19385) 0.90
codegen_es5 71998 ns/iter (± 17746) 85133 ns/iter (± 18894) 0.85
config_for_file 21142 ns/iter (± 6978) 24419 ns/iter (± 6948) 0.87
full_es2015 242484914 ns/iter (± 18911972) 286247027 ns/iter (± 46980065) 0.85
full_es2016 183601713 ns/iter (± 18834565) 211192710 ns/iter (± 42424028) 0.87
full_es2017 202973134 ns/iter (± 10171341) 238404870 ns/iter (± 38650461) 0.85
full_es2018 201353927 ns/iter (± 14774474) 230844364 ns/iter (± 53504452) 0.87
full_es2019 200952997 ns/iter (± 16495066) 220016441 ns/iter (± 18330541) 0.91
full_es2020 197900993 ns/iter (± 13087860) 225810908 ns/iter (± 32030736) 0.88
full_es3 319661510 ns/iter (± 36131705) 327971826 ns/iter (± 64329570) 0.97
full_es5 282108856 ns/iter (± 18709783) 305519339 ns/iter (± 52444340) 0.92
parser 880537 ns/iter (± 77882) 1074953 ns/iter (± 218701) 0.82
transforms_es2015 1697727 ns/iter (± 267469) 1692922 ns/iter (± 355048) 1.00
transforms_es2016 994329 ns/iter (± 148766) 1067705 ns/iter (± 297795) 0.93
transforms_es2017 959469 ns/iter (± 149776) 1130780 ns/iter (± 343205) 0.85
transforms_es2018 967215 ns/iter (± 218061) 1131820 ns/iter (± 367233) 0.85
transforms_es2019 947522 ns/iter (± 158478) 1061806 ns/iter (± 422905) 0.89
transforms_es2020 943794 ns/iter (± 173012) 1100439 ns/iter (± 404328) 0.86
transforms_es3 1944874 ns/iter (± 310723) 1958781 ns/iter (± 455848) 0.99
transforms_es5 1680377 ns/iter (± 383901) 1698294 ns/iter (± 451102) 0.99
ser_ast_node 203 ns/iter (± 18) 229 ns/iter (± 38) 0.89
ser_serde 206 ns/iter (± 14) 242 ns/iter (± 36) 0.85
emit_colors 19683349 ns/iter (± 25198916) 5914080 ns/iter (± 3772914) 3.33
emit_large 40097318 ns/iter (± 54476194) 124925023 ns/iter (± 194877657) 0.32
base_clone 3223653 ns/iter (± 717149) 3769327 ns/iter (± 3489460) 0.86
fold_span 5670201 ns/iter (± 1336944) 7035963 ns/iter (± 2525886) 0.81
fold_span_panic 5826986 ns/iter (± 1149098) 7774076 ns/iter (± 3257852) 0.75
visit_mut_span 3738613 ns/iter (± 618256) 4524281 ns/iter (± 2142394) 0.83
visit_mut_span_panic 3713744 ns/iter (± 577773) 5765586 ns/iter (± 2987761) 0.64
boxing_boxed 210 ns/iter (± 22) 209 ns/iter (± 36) 1.00
boxing_boxed_clone 84 ns/iter (± 19) 96 ns/iter (± 22) 0.88
boxing_unboxed 180 ns/iter (± 15) 193 ns/iter (± 34) 0.93
boxing_unboxed_clone 129 ns/iter (± 16) 92 ns/iter (± 24) 1.40

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 7b4af43 Previous: 303cecb Ratio
emit_colors 19683349 ns/iter (± 25198916) 5914080 ns/iter (± 3772914) 3.33

This comment was automatically generated by workflow using github-action-benchmark.

CC: @kdy1

Please sign in to comment.