typescript文件中的module.exports返回';模块不是模块;
以下模块是用JS文件编写的:typescript文件中的module.exports返回';模块不是模块;,typescript,Typescript,以下模块是用JS文件编写的: module.exports = { propA: 1, propB: 2 } 允许以后从模块导入属性,如: 从'path/to/module'导入{propA} 但是,将文件格式更改为typescript(如module.ts)会导致以下问题,即“模块不是模块” 这是该项目的tsconfig { "compilerOptions": { "target": "esnext", "module": "esnext", "stri
module.exports = {
propA: 1,
propB: 2
}
允许以后从模块导入属性,如:
从'path/to/module'导入{propA}
但是,将文件格式更改为typescript(如module.ts
)会导致以下问题,即“模块不是模块”
这是该项目的tsconfig
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"sourceMap": true,
"noImplicitThis": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
如果有人能建议一种有效的方法来保存module.exports或typescript,我将不胜感激:)
…或者至少可以声明导出对象的模块,该模块以后只允许导入对象的单个属性
export const yourData = {
propA: 1,
propB: 2
}
并从“yourSrc”导入您的数据这可能会有所帮助:这是否回答了您的问题?