What does the @ mean in `import from '@/some/path'`

372 views Asked by At

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.

2

There are 2 answers

0
Étienne Miret On BEST ANSWER

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

{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  },
}
0
eten On

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