0
我已經包括了類型並引用它們。 我不確定這些打字是否正確,因爲我不知道如何寫。但是,這是我做過什麼:Typescript找不到名稱'functionName'
// 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" />