How do I get VS Code to understand my aliases in react native for command click?

Viewed 758

So I'm using a package.json file to create custom aliases in my project

{
  "name": "@name"
}

so that I can change this

import Component from '../../../some/deeply/ambiguous/name';

to this

import `Componentfrom '@name';

However, I can't command + click to jump to that module from the import statement, VS code cannot resolve the path.

There are a couple other ways to do this (https://www.novis.co/post/custom-aliases-in-react-native-with-babel/), is there is any way that I can do aliasing and somehow have visual studio code recognize the path and be able to jump to it?

1 Answers

Mine work and I've just added in the paths to tsconfig, maybe give that a go. Try adding in the paths into tsconfig.json in your root. Close and reopen VSCode.

baseUrl": ".",
"paths" : {
  "@app/*" : ["src/*"]
}
Related