Typescript tsconfig.json在应用程序启动后重置
我用Typescript tsconfig.json在应用程序启动后重置,typescript,Typescript,我用create React app\u name--typescript创建了我的React app。因为Typescript不支持节点路径。我试图在tsconfig.json中使用baseUrl 但是,每次在编译器选项“中放入baseUrl:“src”后运行纱线开始时,baseUrl就会消失。我感觉像是warn start重置tsconfig.json 如何停止它以重置文件 **tsconfig.json** { "compilerOptions": { "target": "e
create React app\u name--typescript
创建了我的React app。因为Typescript不支持节点路径。我试图在tsconfig.json
中使用baseUrl
但是,每次在编译器选项“
中放入baseUrl:“src”
后运行纱线开始时,baseUrl就会消失。我感觉像是warn start
重置tsconfig.json
如何停止它以重置文件
**tsconfig.json**
{
"compilerOptions": {
"target": "es6",
"allowJs": true,
"skipLibCheck": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": ["src"]
}
create react app当前删除了baseUrl
属性,不幸的是,我认为它们当前不支持路径:(
请阅读此处的更多信息。baseUrl问题已在create react app 3中修复。它现在支持两个值—节点模块(默认值)和src
(请参阅此)
使用中的说明升级create react应用程序
如果你想从2.1.x升级到3.0.0
npm install --save --save-exact react-scripts@3.0.0
或
注意:我曾经有jsconfig.json
和tsconfig.json
,但它在开始时抛出了一个错误。删除jsconfig.json
解决了这个问题。有一个解决方法
创建一个新文件,比如“base tsconfig.json”,并将baseUrl配置和路径放在其中。这些不会被CRA覆盖
使用自定义配置扩展主tsconfig.json文件
更多信息。请查看。它对我有效。阅读此解决方案的任何人也可以看到,这不再是事实,请参阅此github pull请求:它从tsconfig/jsconfig启用了set-baseUrel
yarn add --exact react-scripts@3.0.0
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
{
"extends": "./base-tsconfig.json"
}