找不到模块'react-split'的声明文件

5

我正在尝试创建一个分割视图,但是在导入react-split时遇到了问题。

当我将其导入并添加到我的代码中时,我没有看到任何问题。 然后,在我的编辑器上,当我悬停在import Split from "react-split"的行上时,会出现三个点,并提示:

无法找到模块“react-split”的声明文件。'/home/user/Documents/test/node_modules/react-split/dist/react-split.js'隐含地具有“any”类型。 如果存在,请尝试npm install @types/react-split或添加一个包含declare module 'react-split';的新声明(.d.ts)文件。ts(7016)

如果我尝试运行npm install @types/react-split,则会得到

npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2freact-split - Not found npm ERR! 404 '@types/react-split@latest'不在npm注册表中。 npm ERR! 404 您应该向作者提出问题,以发布它(或自己使用该名称!) npm ERR! 404 npm ERR! 404请注意,您还可以从tarball、文件夹、http url或git url安装。

当我创建.d.ts文件并声明模块时,这个问题仍然没有解决,提示消息仍然存在。

有任何想法如何解决这个问题吗?我尝试了所有建议和类似的栈问题,但没有任何解决方法。

编辑:我对Web开发非常新手,它似乎要求使用TypeScript?不知道为什么?我安装了TypeScript,但是该软件包仍无法正常工作。

2个回答

1

@types/react-split-pane已被弃用

您应该使用react-split-pane

react-split-pane提供了自己的类型定义,因此您不需要安装@types/react-split-pane


1

现阶段,认为“Think”可能是正确答案(而不是被接受的答案)。react-split-panereact-split并不相同。我使用了这个index.d.ts - Jon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接