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

The valid path "/*" does not resolve correctly #113

Closed
thesunny opened this issue Mar 29, 2020 · 6 comments
Closed

The valid path "/*" does not resolve correctly #113

thesunny opened this issue Mar 29, 2020 · 6 comments

Comments

@thesunny
Copy link

thesunny commented Mar 29, 2020

Thank you to the contributors for providing this useful library. I know a lot of works goes into this. I've been trying to migrate to typescript and this issue is causing a hangup. My code follows this path setup and with so many files, I don't want to have to rewrite all my import statements.

The following is a valid path in tsconfig.json but will not work with tsconfig-paths. The broken part is /*:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "/*": ["*"]
    }
  }
}

The config above does work properly in VSCode and imports are followed correctly. It maps "/lib/something" for example to "{root}/lib/something"

In my environment, the following tsconfig.json with a tilde works fine with tsconfig-paths so it's likely not a configuration issue:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~*": ["*"]
    }
  }
}

With the tsconfig.json above, tsconfig-paths works correctly.

When I use the "/*" path, I get an error like this:

Error: Cannot find module '/lib/log'
@thesunny thesunny changed the title Path "/*" is broken The valid path "/*" does not resolve correctly Mar 29, 2020
@thesunny
Copy link
Author

thesunny commented Mar 29, 2020

For clarity, this typescript PR shows that it works in typescript: microsoft/TypeScript#27980

@0x80
Copy link

0x80 commented Apr 2, 2020

I just ran into the same issue. Good to know that ~/ works as a workaround for now 👍

@cspotcode
Copy link
Collaborator

Looks like the same as #128

@thesunny
Copy link
Author

Yes, looks the same. But for clarity, this issue was opened first and the other is a duplicate. :)

@cspotcode
Copy link
Collaborator

@thesunny yes, definitely. The other issue links to the bit of code that needs to be changed. Honestly I wanted to link them together so I remember to close both when the bug is fixed.

@jonaskello
Copy link
Member

Fixed in #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants