Import module from root path in TypeScript

后端 未结 5 1842
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 23:02

Let\'s suppose I\'ve a project, and its main source directory is:

C:\\product\\src

Based on this directory, every import path would be rela

5条回答
  •  借酒劲吻你
    2021-01-07 23:36

    I needed to set both baseUrl and rootDir to point to my src folder in tsconfig.json { "compilerOptions": { "baseUrl": "./src", "rootDir": "./src", ... } I could then import .tsx files without needing a prefixed '/' or a relative path.

    e.g. import BreadCrumb from 'components/BreadCrumb'

提交回复
热议问题