使用create-react-app --typescript生成的项目,不能使用ts的alias?
发布于 5 年前 作者 wangchaoduo 6315 次浏览 来自 问答
$ react-scripts start
The following changes are being made to your tsconfig.json file:
  - compilerOptions.jsx must be preserve (JSX is compiled by Babel)
  - compilerOptions.baseUrl must not be set (absolute imports are not supported (yet))
  - compilerOptions.paths must not be set (aliased imports are not supported)

给tsconfig添加上baseUrl、paths属性后便会出现以上log,然后tsconfig中的内容会自动被删除,有没有朋友碰到过同样的问题的。

1 回复

贴一下自动生成的tsconfig

{
  "compilerOptions": {
    "target": "es5",
    "rootDirs": [
      "src"
    ],
    "allowJs": true,
    "skipLibCheck": false,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "rootDir": ".",
    "lib": [
      "es6",
      "dom"
    ],
    "experimentalDecorators": true
  },
  "include": [
    "src"
  ]
}

回到顶部