-
Notifications
You must be signed in to change notification settings - Fork 0
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
Using ts-node with @ imports #1
Comments
I've also been running into an issue with typescript not picking up the module level imports in the
|
I forgot to mention the
There was mention of using jests moduleNameMapper but I have just opted to use standard paths mapping without the helper. For PolyKey, it looks like this in
|
There is still the issue of the |
I'm not sure what it is, but the relative imports show errors in VSCode when used in the test directory unless I include the tests directory as shown two commends above. This is fine until I try to generate typings since now tsc generates typings for the test directory as well which is undesirable. I think the solution for now is to just to use the very common way of importing outside of the |
Note: this issue is just for documentation and has a solution already:
The issue in question is an error that occurs when using imports that use the
@
symbol to denote the module (e.g.import PolyKey from @polykey/PolyKey.ts
). It turns outts-node
doesn't like this and throws an error. There is a whole issue about tsconfig.json/paths not working with ts-node. The solution is to use tsconfig-paths and then suffix all your calls withts-node -r tsconfig-paths/register <file>
. One can do this with a handy alias:alias ts-node='ts-node -r tsconfig-paths/register'
.For webpack, there is also a module for this: https://github.com/dividab/tsconfig-paths-webpack-plugin
The text was updated successfully, but these errors were encountered: