Home > Back-end >  What does the @ mean in `import from '@/some/path'`
What does the @ mean in `import from '@/some/path'`

Time:01-21

Using IntelliJ IDEA to write a webapp in TypeScript, it autocomplete imports from other files of my project like this:

import {Symbol} from '@/components/Symbol';

What is the meaning of the @ here? Where is it documented?

Note that this is when importing files from the same project. Imports from npm packages only use the package name (which may start with a @).

I haven’t found anything about this in TypeScript Module Resolution, and when searching for typescript @ import in Google or SO, it seems the @ character from the query is ignored...

Edit: This is in a Next.js project created with npx create-next-app.

CodePudding user response:

If you are using vite or webpack, then your configuration will have a resolve.alias key to alias strings to a path. Vite documentation Webpack documentation

CodePudding user response:

This turned out to be a tsconfig path, which was put there by npx create-next-app:

{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  },
}
  • Related