Closed jupl closed 4 years ago
I take it you're using ts-node/register
and tsconfig-paths/register
? Are you combining this with @ava/typescript
? (You shouldn't be.)
I can't really help with this I'm afraid, I don't use those tools. Improvements to the recipe are welcome though.
(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)
I'm not using @ava/typescript
. This is a major deal breaker for me as I use parcel
, which uses ~
for path resolution.
I think it makes no sense for this to be closed. You said you can't help, but if you keep this closed the visibility of this issue is limited as perhaps someone who may have insight into this will less likely see this.
if you keep this closed the visibility of this issue is limited as perhaps someone who may have insight into this will less likely see this
Open or closed, it's been my experience in this project that it makes no difference either way. I'll see about getting access to GitHub's new Discussions feature which would be a better fit for resolving this.
Ok. Well I added some more details.
I fought this for a few hours. I don't do it EXACTLY this way, but I found that ava + typescript + modules + paths was a nightmare. I switched to vitest
and it immediately worked out of the box. I would recommend to anyone going the typescript test path to just use vitest.
I am following the instructions as noted here: https://github.com/avajs/ava/blob/master/docs/recipes/typescript.md#using-module-path-mapping
With the following
tsconfig.json
:When I have a file
/some/project/src/users/test.ts
like this:And inside
/some/project/src/users/util.ts
I have something like this:I get an error like this:
The path should resolve to
/some/project/src/common/util
.If I change
~
to-
I get the same error. If I change~
to something else like_
intsconfig.json
andtest.ts
it works just fine. Also I have no issue using~
withtsconfig-paths
in other test libraries like Mocha and Jest. In fact, this is the first time I've come across this issue with ava.EDIT: Almost gave up but I got more details. It seems to occur when my test file imports a file that imports from
~
. If my test file is the only one that uses import from~
then it works fine.In other words this is okay:
But this is not: