Typescript path aliases starting with @ take me to node_mdules/@types

I've set up path aliases in both webpack and typescript, but unfortunately, webstorm is not recognising path aliases starting with @; it seems to think they are Definitely Typed types (I think).

The paths setup in my tsconfig.json:

"baseUrl": "./src",
"paths": {
"@components": ["components"],
"@services": ["services"]

Then in my Vue components:

import FormModal from "@components/common/FormModal"

I get a squiggly under the whole path, and clicking on @components takes me to the node_modules folder.

If I remove the @ from all references, aliases work as expected, and Webstorm can find the folder fine, no warnings, and hyperlinking works.


Can I configure this to work, or do I need to give up on the @ prefix?

I like using @ as it makes it explicit the import is referencing application src.







OK, so I think I solved it with the help of this reply from Elena:

The key thing here seems to be the "/*" at the end of all keys and values:

"foo/*": ["path/to/foo/*"]

I also had to go File > Invalidate Caches / Restart...




Think I spoke too soon!

Intelligence for paths using @ seems to be lacking :(

I can type a @ and get autocomplete for the initial aliases...

But complete a single alias, and nothing more:

If I remove the @ from the alias, it seems to get all the paths again:

Can someone from JetBrains explain what is going on?

(Seems like a bug)



Hey Elena,

Thanks for putting me out of my misery!

I'll revert to using [email protected] paths for now


Please sign in to leave a comment.