Allow Typescript absolute path alias
See original GitHub issueHey, currently the absolute paths from my typescript tsconfig.json are not resolved.
{
"compilerOptions": {
"paths": {
"@svgs/*": [
"svgs/*"
]
}
}
Doing import Dog from '@svgs/dog.svg'
results in an error: Cannot find module '@svgs/dog.svg' from '/Users/lukasoppermann/Repos/next-app/components'
Is there a way to make this work?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Path aliases with TypeScript in Node.js
I've just released a new package Alias HQ, which allows you to reuse your js/tsconfig.json path aliases in Webpack, Jest, Rollup, or any...
Read more >Path aliases with TypeScript in Node.js - Level Up Coding
With path aliases, you can declare aliases that map to a certain absolute path in your application. ... Let's get into it and...
Read more >How To Configure Path Aliases With TypeScript
The path is based on the location of my tsconfig. json file. For this example, I'll set baseUrl to the root of my...
Read more >How to configure and resolve path alias with a Typescript Project
Path alias is a way to define an absolute path in your typescript project with a word, path or a character.
Read more >TypeScript Path Aliases
Path Alias is a TypeScript configuration that maps a custom alias to a path in your project. Thanks to path aliases, the import...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems to be working fine just by installing the babel module-resolver and adding the following to the
.babelrc
and leaving the tsconfig.json as is.Good call; as long as you’re OK duplicating the config in both babel and TS configs, that should work fine.