javascript - 如何将 react-app-rewired 与 TypeScript 一起使用?
问题描述
以下 StackOverflow 答案告诉我如何使用 react-app-rewired 从src
文件夹外部导入 JavaScript 文件,而不弹出应用程序:
https://stackoverflow.com/a/55298684/377011
但是,当将它与文件夹之外的 Typescript 文件一起使用时src
(即import * from '../../myfile.ts'
),我收到以下错误:
Module not found: Can't resolve 'ts-loader' in '...\myapp'
所以我安装了ts-loader
(yarn add ts-loader
),但现在我得到了
Error: TypeScript emitted no output for ...\myapp\src\index.tsx
noEmit
在true
我的tsconfig.json
.
任何想法?
编辑:这是我的tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
解决方案
推荐阅读
- html - 如何验证打字稿中输入标记的类型“target.dataset”属性
- c# - 如何在 c# 的 for each 循环期间发布事件?
- c++ - 有没有办法在来自不同标题的函数之间指向变量?
- sql - 案例表达有问题
- java - 转换地图
> 到地图 > 在 Java 1.8 中 - database - 如何链接 Google 表单以响应现有的 Google 表格?
- python - 对 Pandas Dataframe 中的组合进行并行化/矢量化计算
- javascript - 如何滚动到第一个子 div,而不是一个接一个地滚动到所有目标子 div?
- mysql - 为什么 select count(*) from table_name 这么慢?
- amazon-redshift - 如何设计排序键中有许多列的表?