我试图用TypeScript创建Reactive18应用程序,我试着跟随本指南,但我无法使它工作。我无法将"types": ["react/next", "react-dom/next"]添加到tsconfig文件中。我搞错了:
Cannot find type definition file for 'react-dom/next'.
The file is in the program because:
Entry point of type library 'react-dom/next' specified in compilerOptionsts
Cannot find type definition file for 'react-dom/next'.
The file is in the program because:
Entry point of type library 'react-dom/next' specified in compilerOptionsts另外,我不能从ReactDom中导入'react-dom/client';,我得到了这个错误:
Could not find a declaration file for module 'react-dom/client'. 'C:/Users/bansc/Desktop/youtube-channel/api-calls/my-app/node_modules/react-dom/client.js' implicitly has an 'any' type.
If the 'react-dom' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom'ts(7016)发布于 2022-04-10 17:28:34
上周我花了很长时间才弄明白。在react dom experimental.d.ts文件中:
要在实际项目中加载此处声明的类型,有三种方法。如果您的
tsconfig.json已经在"compilerOptions"部分中有一个"types"数组,那么最简单的方法就是向"types"数组中添加"react-dom/experimental"。
因此,将其添加到您的tsconfig.json中:
"types" : [
"react-dom/experimental"
]https://stackoverflow.com/questions/71808206
复制相似问题