Skip to content
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

Remove abstract fields when disableESTransforms is enabled #732

Merged

Conversation

alangpierce
Copy link
Owner

Fixes #731

disableESTransforms is intended to match the more spec-compliant mode
useDefineForClassFields provided by TypeScript, but it looks like in TS 4.2
they updated the behavior so that abstract fields are removed in addition to
declare fields:
microsoft/TypeScript#40699

In Sucrase, we can implement the same behavior by simply testing for abstract
as well in the place where we test for declare.

Fixes #731

`disableESTransforms` is intended to match the more spec-compliant mode
`useDefineForClassFields` provided by TypeScript, but it looks like in TS 4.2
they updated the behavior so that `abstract` fields are removed in addition to
`declare` fields:
microsoft/TypeScript#40699

In Sucrase, we can implement the same behavior by simply testing for `abstract`
as well in the place where we test for `declare`.
@alangpierce alangpierce marked this pull request as ready for review August 2, 2022 01:00
@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #732 (07196e5) into main (be09d6b) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #732   +/-   ##
=======================================
  Coverage   87.17%   87.17%           
=======================================
  Files          54       54           
  Lines        5722     5722           
  Branches     1349     1349           
=======================================
  Hits         4988     4988           
  Misses        466      466           
  Partials      268      268           
Impacted Files Coverage Δ
src/util/getClassInfo.ts 87.85% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@github-actions
Copy link

github-actions bot commented Aug 2, 2022

Benchmark results

Before this PR: 410.2 thousand lines per second
After this PR: 416.9 thousand lines per second

Measured change: 1.63% faster (0.21% faster to 6.36% faster)
Summary: Probably faster

@alangpierce alangpierce merged commit 44eb2ae into main Aug 2, 2022
@alangpierce alangpierce deleted the remove-abstract-fields-with-disable-es-transforms branch August 2, 2022 01:07
1Lighty pushed a commit to Astra-mod/sucrase that referenced this pull request Aug 14, 2022
…ce#732)

Fixes alangpierce#731

`disableESTransforms` is intended to match the more spec-compliant mode
`useDefineForClassFields` provided by TypeScript, but it looks like in TS 4.2
they updated the behavior so that `abstract` fields are removed in addition to
`declare` fields:
microsoft/TypeScript#40699

In Sucrase, we can implement the same behavior by simply testing for `abstract`
as well in the place where we test for `declare`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disableESTransform has unexpected side effects
1 participant