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

[Feature] Support baseUrl without paths #63

Closed
haoadoreorange opened this issue Nov 2, 2021 · 9 comments · Fixed by #67
Closed

[Feature] Support baseUrl without paths #63

haoadoreorange opened this issue Nov 2, 2021 · 9 comments · Fixed by #67

Comments

@haoadoreorange
Copy link

As title said, should it work without any paths but only baseUrl ?

@raouldeheer
Copy link
Contributor

Do you mean this?

@haoadoreorange
Copy link
Author

hmm no I mean, currently tsc-alias work with paths field in tsconfig. But setting only baseUrl has similar effect, could it work with that only ?

@raouldeheer
Copy link
Contributor

Right now it wouldn't work, because tsc-alias makes a list of all aliases and matches that with the imports. So when paths is empty there won't be any aliases to match so it won't find any results.

@haoadoreorange
Copy link
Author

is that something viable ?

@justkey007
Copy link
Owner

@haoadoresorange
How setting only baseUrl has a similar effect? Are you saying that without defining the paths option in tsconfig you can use aliases using only baseUrl?

@raouldeheer
Copy link
Contributor

The requested behavior is that "index" will be replaced by "${baseurl}/index". Where index can be any path in the baseurl directory.

@raouldeheer
Copy link
Contributor

I've got a prototype of this feature working; I'll improve it tomorrow. Haven't fully tested it yet so I'm not sure if it's a viable solution.

@justkey007
Copy link
Owner

@raouldeheer @haoadoresorange
Thank you, the request was well understood

@ChrisChiasson
Copy link

@raouldeheer it seems like if we want baseUrl=".", so that absolute imports start with src/ we would need paths: {"src/*": "src/*"} in tsconfig.json. I was able to figure this out by taking project 16 from PR #67 and changing baseUrl and all the imports. I used project 10 for comparison. Thank you for your work on this project!

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

Successfully merging a pull request may close this issue.

4 participants