Abd*_* Ch 15 javascript typescript reactjs material-ui
我正在使用 Material-ui 与 TypeScript 模板进行反应。我的所有代码都工作正常,但我在多行上收到此错误(不是错误警告,而是在我的代码呈现时出现红线)
Could not find a declaration file for module 'react/jsx-runtime'. 'C:/Users/dell/Desktop/Web current Projects/typescript/card/node_modules/react/jsx-runtime.js' implicitly has an 'any' type.
If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react`ts(7016)
Run Code Online (Sandbox Code Playgroud)
根据 @NearHuscarl 的评论,快速解决方法是为react/jsx-runtime
. 您可以通过打开react-app-env.d.ts
项目根目录中的文件(使用 create-react-app 时默认创建)来完成此操作。然后添加以下脚本:
declare module "react/jsx-runtime" {
export default any;
}
Run Code Online (Sandbox Code Playgroud)
create-react-app 团队不认为这是 create-react-app 需要解决的问题,并建议这是 typescript 版本 4 的问题。因此,您也可以降级您的 typescript 版本,直到 typescript 团队提供修复更高版本。
归档时间: |
|
查看次数: |
24133 次 |
最近记录: |