gpt4 book ai didi

javascript - JSX 错误 : Property does not exist on type 'JSX. IntrinsicElements

转载 作者:搜寻专家 更新时间:2023-10-30 21:35:13 25 4
gpt4 key购买 nike

我将容器转换为 .jsx 文件,但现在在渲染方法中我的 HTML 元素上出现以下错误:

Property does not exist on type 'JSX.IntrinsicElements.div

Property does not exist on type 'JSX.IntrinsicElements.h1


包.json

{
"name": "moonholdings.io",
"version": "0.1.0",
"private": true,
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/ --source-map",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive --source-map",
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
},
"dependencies": {
"node-sass-chokidar": "^1.3.3",
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts-ts": "2.17.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/react": "^16.4.14",
"@types/react-dom": "^16.0.5",
"@types/react-redux": "^6.0.9",
"@types/react-router": "^4.0.25",
"@types/react-router-dom": "^4.2.6",
"@types/react-router-redux": "^5.0.14",
"@types/redux": "^3.6.31",
"ramda": "^0.25.0",
"typescript": "^3.0.3"
}
}

登录容器.js

    import * as React from 'react';
import { connect } from 'react-redux';

// Actions
// import { addCoins } from 'actions/coins';

interface IProps {
loginActions: any
}

interface IState {
email: string;
password: string;
}

class LoginContainer extends React.Component<IProps, IState> {

public state: IState = {
email: '',
password: ''
};

public render() {
return (
<div id="login-container">
<h1>Login</h1>
</div>
);
}
}

// const mapDispatchToProps = dispatch => ({
// addCoins: (...args) => dispatch(addCoins(...args))
// });

export const LoginContainerJest = LoginContainer;

export default connect(null, null)(LoginContainer);

我有 rm -R node_modules,我也确实看到我安装了两次 "@types/react-redux",但我修复了它。重新安装 Typescript,仍然得到相同的 (2312,14): Duplicate identifier 'LibraryManagedAttributes'. 错误 :(

最佳答案

找到答案:Typescript Error: TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'

  • 确保你的文件中有 import * as React from 'react'
  • 更新 React 的类型 npm install @types/react

关于javascript - JSX 错误 : Property does not exist on type 'JSX. IntrinsicElements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52322802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com