-
Notifications
You must be signed in to change notification settings - Fork 2
Global types are breaking type tets #358
Comments
Thanks for reaching out! Checked your reproduction. Feels like something is wrong on Hm.. Interesting what is going on here. I will try to find time to think about it and to dig around. Actually! A better solution could be simply to wait for a brand new type testing tool, which I mentioned here: jest-community/jest-runner-tsd#32. Just checked it, your reproduction is passing without any issues using this runner. It is near ready to be published. Should be out in 4-6 weeks. |
Quick workaround. Add the following to the test file: import '../types.d.ts';
|
Thanks for such a quick response and explanation! It's good to know that we had a good intuition and it's actually an existing limitation. We'll wait for the new runner - amazing work by the way! I'll leave it up to you to decide whether to close or keep this issue open but I personally think it's good to keep it open :) |
TSTyche, the testing tool I promised, is released. For details, see jest-community/jest-runner-tsd#32 (comment) Thanks for raising the issue. It gave me another bit of motivation to move on with TSTyche. Give it a try, please. It works as expect with case you have described here. So I can close now (; |
Hi, first of all I wanted to say thank you for the hard work on the library! 馃槂
At our project we wanted to introduce type testing using
tsd-lite
along withtsd-runner-jest
. We did a basic setup according to the docs to make a sort of MVP. The setup is mirrored in this repro repo.The problem that we encountered is that types from the global scope seem to break the type tests. In this repro we're creating a type test but also importing a function to test its signature. This function is using a global type.
After running
npx jest --config jest.config.tsd.js
you can see that typeThisIsNull
cannot be found, but it is used in theid
function. The test would also break if we usedThisIsNull
directly in the type tests since it would notbe recognized unless it's explicitly imported (which would make it non-global).
Steps to reproduce:
git clone
followed bynpm i
npx jest --config jest.config.tsd.js
Actual result:
Expected result:
ThisIsNull
type should be known to the runner when importing theid
function, error shouldn't be thrownThe question
So we wanted to ask whether we can do something about it right now, maybe we missed something? And if we can - would it require us to get rid of global types or do some hacks to get around problems surrounding them? Or maybe that problem is unsolvable for the time being?
Please let us know, thanks for any help in advance!
CC @erheron
The text was updated successfully, but these errors were encountered: