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

Cannot find modules -- support TS Paths Aliases #322

Closed
rickkky opened this issue Nov 12, 2019 · 1 comment
Closed

Cannot find modules -- support TS Paths Aliases #322

rickkky opened this issue Nov 12, 2019 · 1 comment
Labels
solution: duplicate This issue or pull request already exists solution: workaround available There is a workaround available for this issue topic: TS Paths Aliases Related to using aliases with TypeScript paths

Comments

@rickkky
Copy link

rickkky commented Nov 12, 2019

Current Behavior

I have a.ts and b.ts in my src folder.

- src
  |- a.ts
  |- b.ts

And in b.ts, I import a.ts by using import like the following statement:

import a from 'a'

Here is my tsconfig.json:

{
  "include": ["src", "types", "test"],
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "lib": ["dom", "esnext"],
    "importHelpers": true,
    "declaration": true,
    "sourceMap": true,
    "rootDir": "./",
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "*": ["src/*", "node_modules/*"]
    },
    "jsx": "react",
    "esModuleInterop": true
  }
}

And I can build correctly by using tsdx build. But there comes an error when using tsdx test:

Cannot find module 'a' from 'b.ts'

Expected behavior

This question makes me confused.

I think since it can build successfully, it should be able to resolve all my modules correctly when testing.

How can I make it right when I want to import my own modules like:

import somthing from 'justMyModuleName'

Your environment

Software Version(s)
TSDX ^0.11.0
TypeScript ^3.6.4
npm 6.4.1
Node v10.15.0
Operating System Win10
@swyxio
Copy link
Collaborator

swyxio commented Dec 4, 2019

thanks for filing - absolute imports are buggy right now. closing this in favor of #336 - if you can find a fix, please be our guest.

Maintainer (agilgur5) edit: duplicate of #336 which is a duplicate of #91

@swyxio swyxio closed this as completed Dec 4, 2019
@agilgur5 agilgur5 added solution: duplicate This issue or pull request already exists topic: TS Paths Aliases Related to using aliases with TypeScript paths labels Mar 10, 2020
@agilgur5 agilgur5 changed the title Can not find modules when testing Can not find modules -- support TS Paths Aliases Mar 10, 2020
@agilgur5 agilgur5 changed the title Can not find modules -- support TS Paths Aliases Cannot find modules -- support TS Paths Aliases Mar 10, 2020
@agilgur5 agilgur5 added the solution: workaround available There is a workaround available for this issue label Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: duplicate This issue or pull request already exists solution: workaround available There is a workaround available for this issue topic: TS Paths Aliases Related to using aliases with TypeScript paths
Projects
None yet
Development

No branches or pull requests

3 participants