gpt4 book ai didi

javascript - 将 Typescript 2 @Types 与 typescript 1.8.10 一起使用

转载 作者:数据小太阳 更新时间:2023-10-29 05:37:48 26 4
gpt4 key购买 nike

目前我正在尝试在我的项目中使用 d3-drag v4 类型。正在使用 Ts 1.8.10,尚未准备好迁移到 TS2 测试版。

d3-v4 类型库位于此处: https://github.com/tomwanzek/d3-v4-definitelytyped

我尝试使用以下方式安装类型:

typings install d3-drag=github:tomwanzek/d3-v4-definitelytyped/src/d3-drag/index.d.ts#4d09073c046b6444859c66ff441f1e7691777d0f --save

但我收到以下错误:

typings ERR! caused by /tomwanzek/d3-v4-definitelytyped/47eae6d/src/d3-selection.d.ts responded with 404, expected it to equal 200

我发现有人在这里问同样的问题:

https://github.com/tomwanzek/d3-v4-definitelytyped/issues/93

但它没有回答我的问题,因为我现在还不能迁移到 ts2。有没有在 TS 1.8.10 中使用 @types?

最佳答案

同时我创建了一个 d.ts 文件以便能够使用拖动。 没有智能感知,也没有类型检查,但至少我可以使用拖动库。

 declare var d3Drag;
declare module 'd3-drag'
{
export = d3Drag;
}

我在我的代码中这样使用它:

import * as d3Drag from 'd3-drag';

...
let dragBehaivor = d3Drag.drag().on("start", dragStartFunction);

关于javascript - 将 Typescript 2 @Types 与 typescript 1.8.10 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39344686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com