我刚刚将React项目从javascript转换为类型记录,我有很多实例,在目录中有一个索引文件,并从相应的目录导出所有函数/组件。例如,目录可能如下所示:
components
|--index.js
|--ComponentA
|--ComponentB
|--ComponentC
|...index.js将包含:
export ComponentA from './ComponentA'
export ComponentB from './ComponentB'
export ComponentC from './ComponentC'
...我相信babel皈依如下:
export { default as ComponentA } from './ComponentA'
...我已经将所有..js/..jsx文件转换为. to /..tsx,并且我使用webpack与babel-加载程序一起编译这些文件。每件事都运行得很好,但我在我的编辑中出现了错误,因为打字本不了解这些输出。下面是我的tsconfig.json文件:
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": false,
"module": "es6",
"target": "es6",
"jsx": "preserve",
"lib": ["es5", "es6", "dom"],
"esModuleInterop": true,
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true
},
"include": [
"./src/**/*"
],
"types": [
"@reachify/graphql-schema"
],
"awesomeTypescriptLoaderOptions": {
"reportFiles": [
"./src/**/*"
]
}
}和.eslintrc.json:
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
"browser": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint/eslint-plugin"
]
}我怎样才能得到打字稿来理解export Component from './Component**?**
发布于 2019-12-22 16:21:16
正如注释中提到的,这看起来仍然是第1阶段的特性,还没有在类型记录中实现。
https://stackoverflow.com/questions/59432415
复制相似问题