npx create-react-app my-app --template typescript
Copy the code

Typescript created with ceate-react-app does not see the associated config file by default.

However, the configuration file can be ejected using YARN eject.

The YARN eject operation is irreversible.

You should see the following structure:

You can then update the Webpack configuration to use the alias.

// config/webpack.config.js. modules.export = { ...resolve: {...alias: {...The '@': path.resolve(__dirname, '.. /src')}}}Copy the code

Update Typescript configuration to use aliases:

// tsconfig.json
{
  "compilerOptions": {..."baseUrl": ". /"."paths": {
      "@ / *": [ "src/*"]}},... }Copy the code

This allows you to use the alias in your project.