0

webpack resolve setted like this

    resolve: {
        alias: {
            '@': path.resolve(__dirname, '../src/')
        },
        extensions: [ '.tsx', '.ts', '.js' ]
    }

How to make this work in typescript

enter image description here

Jesse Luo
  • 127
  • 1
  • 8
  • 1
    Do these answer your question? https://stackoverflow.com/questions/38601592/typescript-import-path-alias and https://stackoverflow.com/questions/40443806/webpack-resolve-alias-does-not-work-with-typescript – Lin Du May 11 '22 at 03:49
  • the code compiled well, but Vscode still has error warning – Jesse Luo May 11 '22 at 06:10

1 Answers1

0

The following steps solved my problem:

  1. Set paths in tsconfig.json
{
  "compilerOptions": {
     "paths": {
        "@/*": ["./src/*"]
     }
  }
}
  1. Ctrl + Shift + P > TypeScript: Restart Ts server
Jesse Luo
  • 127
  • 1
  • 8