我有以下主题文件,由于某些原因需要用ES5编写:
导致以下错误的原因是:
module.exports.theme = {
primaryColor: 'blue',
borderSize: '2px',
// ...
}
我想在Typescript文件中导入它(在create-react-app环境中)。因此,我按照以下步骤操作:
import { theme } from "../../../../session/theme";
导致以下错误的原因是:
Attempted import error: 'theme' is not exported from '../../../../session/theme'.
我还试过使用module.exports.default = { ... }
导出,并导入默认值,但它基本上也会显示相同的信息(没有默认导出)。
我该如何解决这个问题?
我的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"]
}