Open PindaPixel opened 1 year ago
Hi, @PindaPixel. Thanks for using the library!
I'm assuming the error only shows up when running Jest, right? Can you provide a sample test file which produces that error? A minimal project reproducing the error might also make it easier to identify the cause.
Of course! I created one here: https://github.com/PindaPixel/tsd-transform-error-repro
Ok, it took me a while but I think I got it figured out.
The error you are reporting is happening because your transform pattern is too specific. If you change "^.*(\\.|\\/)(test\\.ts)$"
to simply "^.*\\.ts$"
that error goes away, but then we get some other issues.
Chaining transforms is only supported by version 27.1.3
of ts-jest
(see this: https://github.com/kulshekhar/ts-jest/issues/3372). If you change ts-jest
to that version you get some peer dependency errors because your version of Jest is not supported by ts-jest
. You can fix that with npm package.json overrides, but then we hit another issue: jest-chain-transform
became unsupported by Jest versions 28 and higher and an error is thrown, because of this: https://jestjs.io/docs/28.x/upgrading-to-jest28#transformer
So, without fixing jest-chain-transform
I think the only way to use jest-tsd-transform
is to downgrade Jest to <28.0.0
while setting ts-jest
to 27.1.3
.
Upon further investigation, it isn't jest-chain-transform
but ts-jest<28
that became unsupported, as it returns a simple string instead of the object the new versions of Jest expect. However, it is possible to make a simple change to jest-chain-transform
to "fix" the return of ts-jest
.
Alternatively it might be preferable to get https://github.com/kulshekhar/ts-jest/issues/3372 on the newest version of ts-jest
so we don't have to use an old version, but apparently the change required for that breaks something else, which is why it got removed after 27.1.3
. I think it is easier to propose a little change to jest-chain-transform
, unless you need some feature from the newest versions of ts-jest
.
Another even easier alternative: making a tiny transformer to add to the end of the chain, with the sole purpose of fixing the return of the previous transforms. I can try making a package for that when I have some time.
@PindaPixel I just updated jest-tsd-transform
, embedding version 27.1.3
of ts-jest
and fixing its return. Now you don't have to chain transforms anymore, and you should be able to use jest-tsd-transform
with any version of Jest.
Please update to version 1.1.1
, change jest.config.js
so you don't chain transforms anymore and let me know if you still get any errors!
I import a type (with or without
type
annotation, either way it breaks) from a library, and it seems to break when I do:Config:
What can I do to fix this?