1

MacBook Pro 2019 - Catalina

I'm working on a create-react-app project which allows me to set an environment variable so instead of:

import { caseStudies } from '../../constants/containers/caseStudies';

I can simply write:

import { caseStudies } from 'constants/containers/caseStudies';

Which of course simplifies things a lot with not having to worry about paths so much.

However, right-clicking caseStudies and selecting Go to Definition, works on the first instance, but not the second, simplified instance.

I seem to remember this does work on Windows (haven't got a machine to check) so I'm wondering if it's a Mac problem?

Is there a solution for this?

1 Answer 1

3

you can do that like this =>

option one ->

  1. Use Path Intellisense extension, make your own workspace config work with extension: https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense
  2. add custom workspace settings like

    {
      "path-intellisense.mappings": {
      "@app": "${workspaceRoot}/app"
      "@internals": "${workspaceRoot}/internals"
      }
    }
    

option two ->

you create jsconfing.json in your project root and the content is ==>

{
"compilerOptions": {
 "target": "es2017",
 "allowSyntheticDefaultImports": false,
 "baseUrl": "./",
  "paths": {
   "Config/*": ["src/config/*"],
   "Components/*": ["src/components/*"],
   "Ducks/*": ["src/ducks/*"],
   "Shared/*": ["src/shared/*"],
   "App/*": ["src/*"]
 }
},
 "exclude": ["node_modules", "dist"]
}

you can edit the setting to be like you wish Happy Coding :/:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.