0

以下のtransormerメソッドは実際には匿名であるべきですが、typescriptでは許可されていません:

class Proj {
    static (a, b): {
        forward: (p: Point) => Point;
        inverse: (p: Point) => Point;
    };
    static defs(name: string): any;
    static defs(name: string, def: string): void;
    static transform(from: any, to: any, pt: Point);
    static parse(sr: string): any;
}

では、次のことが可能になるように、これをどのように定義できますか?

import proj = require("proj");
proj("EPSG:3857", "EPSG:4326").forward([0,0]);
4

1 に答える 1

1

以下のようなものをお探しですか?関数とモジュールを同じ名前で宣言すると (関数はモジュールの前に宣言する必要があります。そうしないとエラーが発生します)、それらはマージされます。

以下は、いくつかの小さな変更を加えたコードです (いくつかの機能を削除しました)。

interface Item {
    forward: (p: Point) => Point;
    inverse: (p: Point) => Point;
}
function Proj(a, b): Item {
    return null;
}
module Proj {
    export function defs(name: string): any {
        return null
    }
}

Proj.defs("");
Proj(1 ,3).forward(null);
于 2015-04-20T16:46:22.103 に答える