简体   繁体   中英

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

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 .

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM