我想将tsconfig.json添加到现有的react项目中。我需要的是js / jsx文件中的类型检查和intellisense。但是某些文件在类型上缺少属性时会出现ts2345错误。
我尝试配置tsconfig.json文件,但没有任何效果。
我遇到以下错误:
(property) param1: any
Argument of type '{ param1: string; }' is not assignable to parameter of type '{ param1: any; param2: any; param3: any; param4: any; param5: any; }'.
Type '{ param1: string; }' is missing the following properties from type '{ param1: any; param2: any; param3: any; param4: any; param5: any; }': param2, param3, param4, param5ts(2345)
//testCall.js
import { request } from "./testSource"
const param1 = "ok"
request({
param1 // HERE IS ERROR
})
//testSource.js
export const request = ({
param1,
param2,
param3,
param4,
param5,
}) => {
//some code
}
//tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"allowJs": true,
},
"include": [
"./src/**/*"
]
}
我想使函数具有多个回调,但是我也不想总是初始化所有参数。