例如,当我这样做时:
import type React from 'react';
function Foo({ children }: React.PropsWithChildren<{}>);React.PropsWithChildren是从哪里来的?我对DefinitelyTyped的工作原理了解有限,但没有node_modules/@types/react文件夹,我也从未安装过@types/react。
发布于 2020-08-15 16:34:38
我想你想知道TypeScript是如何解析PropsWithChildren的。但你说过你没有安装@types/react。我认为在这种情况下,TypeScript编译器无法解决这个问题。
如果您想在React中使用TypeScript,请先安装@types/react
Foo.tsx
import React from 'react';
function Foo({ children }: React.PropsWithChildren<{}>);https://stackoverflow.com/questions/63424069
复制相似问题