typescript - 如何在joint.d.ts、jointjs中扩展命名空间
问题描述
我正在尝试在jointjs中创建自定义元素,但我有点陷入打字稿类型的问题。我不知道如何扩展我的命名空间/接口,所以我可以轻松地创建新的jointjs 元素。
我正在使用 React,但我认为它不会有帮助。
我得到的错误是
元素隐式具有“任何”类型,因为“html”类型的表达式不能用于索引类型“typeof 形状”。类型“typeof 形状”上不存在属性“html”
错误 > 关节形状 ['html'] = {};
import * as joint from 'jointjs';
const BeerObject = (graph: joint.dia.Graph) => {
joint.shapes['html'] = {};
joint.shapes['html'].Element = joint.shapes.basic.Rect.extend({
defaults: joint.util.deepSupplement({
type: 'html.Element',
attrs: {
rect: { stroke: 'none', 'fill-opacity': 0 }
}
}, joint.shapes.basic.Rect.prototype.defaults)
});
};
export default BeerObject;
解决方案
推荐阅读
- webpack - stylelint 在解析 LESS 变量时抛出 at-rule-* 错误
- python - 提高 Matplotlib 绘图和 OpenCV 视频处理性能
- angular - 升级 cli 版本 7.3.6 后,.scss 中的加载程序中的错误未返回字符串
- java - 如何使用单一责任原则重构我的服务?
- c - 如何为每个函数调用或宏构建一个具有一个字段的结构?
- javascript - 在javascript中传递echo php
- angular - 如何修复“ng build --prod --deploy-url="/wp-content/themes/{name_theme}/dist/" - 它不能正常工作
- python - python sqlite3是否支持rank函数
- java - 使用 ajax 请求发布大型 JSON 对象
- mysql - Pyspark 在读取 MySQL 数据库时出现时间戳问题