2
我正在嘗試爲mapbox-gl-draw項目創建一個類型化的定義。但失敗了。有人可以提供一些提示嗎?mapbox-gl-draw的Typescript定義d.ts
JavaScript文件是這樣
'use strict';
var Setup = require('./src/setup');
var Options = require('./src/options');
var API = require('./src/api');
const Constants = require('./src/constants');
var Draw = function(options) {
options = Options(options);
var ctx = {
options: options
};
var api = API(ctx);
ctx.api = api;
var setup = Setup(ctx);
api.addTo = setup.addTo;
api.remove = setup.remove;
api.types = Constants.types;
api.options = options;
return api;
};
module.exports = Draw;
window.mapboxgl = window.mapboxgl || {};
window.mapboxgl.Draw = Draw;
我index.d.ts就像
declare namespace mapboxgl {
export function Draw(options?:any):any
}
declare module 'mapbox-gl-draw' {
export = mapboxgl;
}