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

fix(classes): fixed transformer ttypescript / ts-patch support #556

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

nonara
Copy link
Contributor

@nonara nonara commented Jun 22, 2023

Hello.

I got a bug report on ts-patch:

Upon investigating, I found that it had to do with an issue in the @automapper/classes/transformer-plugin transformer.

The issue seems to be that the instructions are incorrect for use with ttypescript / ts-patch, and there is currently no export which would work with them.

Background

For some background, I wrote ts-patch, which was in parallel to ttypescript for a while.

After some time, tts wasn't being maintained any more, but users would open PRs to propagate my logic in. More recently, ttypescript has effectively been deprecated, as it no longer supports TS v5+, and it seems there are no plans to.

I did significant rewrites to ts-patch, where it's diverged too much for it to be propagated in, and it also now has an in-memory compiler, so tts is no longer needed.

Changes

I made three changes.

First, the signature of your default export was in a format that wouldn't work for ttypescript or ts-patch. You can see the signatures here:

Essentially, we're looking for a transformer factory. Our default is the "program" type.

Your before export almost would have worked, but the order of program and options was reversed. As a result, I added the tspBefore wrapper.

The second change was to update the doc to include the import key, as it is necessary, since we can't use the default export.

Lastly, I updated the instructions to point to ts-patch instead of tts, due to it being effectively deprecated. That said, if anyone uses this same config with tts, using typescript <5, it will work for that as well.

You're welcome to make any changes that you'd like! I just wanted the submission to be as complete as possible to save you some time.

Take care!

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

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.

2 participants