【发布时间】:2018-01-25 15:37:45
【问题描述】:
我已经包含了类型并引用了它们。 我不确定打字是否正确,因为我不知道如何写。但这就是我所做的:
// This is where I'm getting Cannot find name 'Polylabel'
geometry: polylabel(feat.geometry.coordinates)
我已经包含了这些类型:
declare module "polylabel" {
/**
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
*
* @name polylabel
* @function
* @param {Array<number>} polygon - Given polygon coordinates in GeoJSON-like format
* @param {number} precision - Precision (1.0 by default)
* @param {boolean} debug - Debugging for Console
* @return {Array<number>}
* @example
* var p = polylabel(polygon, 1.0);
*/
function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
namespace polylabel {}
export = polylabel;}
并引用如下:
/// <reference path="globals/@types/polylabel/index.d.ts" />
【问题讨论】:
-
您声明的内容应该像 polylabel.polylabel(...) 一样使用。
标签: node.js typescript typescript-typings