react-beautiful-dnd 不会编译

问题描述

我已经安装了 react-beautiful-dnd 并且运行了一段时间,突然间我现在从 node_modules 收到一个错误,关于 create-react-app 无法编译 react-beautiful- 中的文件 position.js- dnd 包。我已经研究过将破坏性更改推送到他们的存储库,但 2 个月前没有什么不同,我使我的缓存无效并重新启动(在 webstorm 上)什么也没做,最后我删除了我的 node_modules 并重新安装了它们,但仍然发生错误

enter image description here

enter image description here

鉴于其扩展名,尝试将文件编译为 javascript 似乎是正确的,但是代码似乎是 Typescript,我查看了存储库,确实 github 报告它是 100% javascript,但我看到的大多数文件包括上面截图似乎使用了Typescript。我的印象是打字稿不能直接从 javascript 文件运行,我不正确吗?什么可能导致错误

谢谢

解决方法

要使用 import type,您应该将 type 放在大括号之前:

import type { Position } from 'css-box-model';

另外,如果你想导入'css-box-model'中的类型定义及其方法或常量,import them separately

import { constant } from 'css-box-model';
import type { interface } from 'css-box-model';

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...