Skip to content

Move legacy decorators into separate transform #48669

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

Merged
merged 1 commit into from
Jun 3, 2022
Merged

Conversation

rbuckton
Copy link
Contributor

This moves the portion of the ts transform that handles decorators to a separate transformer to pave the way for eventual support for native ECMAScript decorators now that the proposal has reached Stage 3.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Apr 13, 2022
3 > ^^^
4 > ^^^^^^^^^^
5 > ^
3 > ^^^^^^^^^^^^^
Copy link
Member

Choose a reason for hiding this comment

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

This shouldnt have changed right? i mean we do want = as separate thing in sourcemap ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a consequence of performing transforms in two steps where we first remove the modifiers (in the ts transform), and then remove the decorators (in the legacyDecorators transform). It's not the = that is mapped here, but rather the start of the function expression that is no longer mapped to the start of the private modifier since that modifier no longer exists when the decorators transform is run. I debated accepting this change, but modifiers aren't a valid position for an inline breakpoint so this doesn't seem to affect the debug experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out the information is available, since the decorators and modifiers arrays exist and have a pos/end but are empty. The issue is that moveRangePastDecorators and moveRangePastModifiers only use the end of a NodeArray if the array isn't empty. I may be able to change that to get the necessary information to insert a valid source map position here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed up a change to address this. There are still changes to the sourcemap emit, but these changes should be an improvement as the mappings are more consistent.

@rbuckton
Copy link
Contributor Author

rbuckton commented May 9, 2022

@sheetalkamat can you take another look?

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Does this need to go into 4.8 fairly early to see if it's breaky? It looks fine to me currently.

@rbuckton
Copy link
Contributor Author

rbuckton commented Jun 3, 2022

That would be my preference yes. The sooner we can get feedback on any issues with the API changes, the better.

Copy link
Member

@sandersn sandersn 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 to me. @sheetalkamat can you take another look too?

@rbuckton rbuckton merged commit cb1bc61 into main Jun 3, 2022
@rbuckton rbuckton deleted the legacyDecorators branch June 3, 2022 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants