Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
typescript文件中的module.exports返回';模块不是模块;_Typescript - Fatal编程技术网

typescript文件中的module.exports返回';模块不是模块;

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

以下模块是用JS文件编写的:

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”导入您的数据

这可能会有所帮助:这是否回答了您的问题?