我正在尝试在 .tsx 函数组件的 render() 函数中包含一个 .jsx(或 .js)React 类有状态组件。根据我尝试的方法,我收到不同的错误“没有属性与此调用匹配”。
我尝试了在 github 上看到的东西,例如:
//...
/* tslint:disable */
const JSProfileDetails: any = ProfileDetails;
/* tslint:enable */
return (
// ...
<JSProfileDetails
profileName={profileName}
profileDetails={profileDetails}
profileInitialValues={profileInitialValues}
/>
但实际上到目前为止没有任何效果。我将该组件保存在 .jsx/.js 中,因为输入它是相当不可能的。
我在typescript@3.7.2,我的tsconfig.json是:
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "build/dist",
"module": "esnext",
"target": "es6",
"lib": ["es2019", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"importHelpers": true,
"strictNullChecks": false,
"suppressImplicitAnyIndexErrors": true,
"types": ["react", "node", "jest"],
"noUnusedLocals": true,
"skipLibCheck" : true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts"
]
}
我得到的确切错误是:
o overload matches this call.
Overload 1 of 2, '(props: TypographyProps, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Componen
t<any, any, any>)>) | (new (props: any) => Component<any, any, any>)> | Component<...>', gave the following error.
Type 'string' is not assignable to type 'ElementType<HTMLAttributes<HTMLElement>>'.
Overload 2 of 2, '(props: PropsWithChildren<TypographyProps>, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (prop
s: any) => Component<any, any, any>)>) | (new (props: any) => Component<...>)> | Component<...>', gave the following error.
Type 'string' is not assignable to type 'ElementType<HTMLAttributes<HTMLElement>>'.
MMTTMM
湖上湖
相关分类