【发布时间】:2018-04-16 22:45:21
【问题描述】:
我在 TypeScript 项目中使用 Leaflet Library (http://leafletjs.com)。
我在地图上显示使用选项配置的标记:http://leafletjs.com/reference-1.3.0.html#marker-l-marker
我正在尝试在我的项目中使用这个库:https://github.com/bbecquet/Leaflet.RotatedMarker
我正在尝试向 Marker 的第二个参数添加更多选项,但出现打字稿错误:
ERROR in src/app/app.component.ts(61,7): error TS2345: Argument of type '{ rotationAngle: number; }' is not assignable to parameter of type 'MarkerOptions'.
Object literal may only specify known properties, and 'rotationAngle' does not exist in type 'MarkerOptions'
我试图创建一个打字脚本或文件来允许我这样做。
/// <reference types="leaflet" />
declare module L {
export interface MarkerOptions {
rotationAngle: number;
rotationOrigin: string;
}
}
可能是这样的: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/leaflet/index.d.ts#L1470
我缺少什么来完成这项工作?
如何为不提供开箱即用类型的 JavaScript 代码或第三方库创建自定义类型?
这是一个 MCVE:https://github.com/badis/typescript-stackoverflow-question
【问题讨论】:
标签: javascript angular typescript