Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97420

VS Code not recognising module aliases in Expo project

$
0
0

I've set up import aliases in my Expo project. It's compiling fine however VS Code doenst recognise the import:

In tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "jsx": "react-native",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "noEmit": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "baseUrl": "./",
    "paths": {
      "home": ["./"]
    }
  }
}

In babel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      [
        "module-resolver",
        {
          alias: {
            home: "./"
          }
        }
      ]
    ]
  };
};

The import in the file works: import Thing from "home/src/thing";

I thought this would make VS Code aware of the alias but it appears not to do anything

In jsconfig.json:

{
  "compilerOptions": {
    "target": "es2017",
    "allowSyntheticDefaultImports": false,
    "baseUrl": "./",
    "paths": {
      "home/*": ["./*"]
    }
  },
  "exclude": ["node_modules", "dist"]
}

Viewing all articles
Browse latest Browse all 97420

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>