0

The transormer method below should actually be anonymous but that is not allowed in 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;
}

So how can this be defined such that the following is possible?

import proj = require("proj");
proj("EPSG:3857", "EPSG:4326").forward([0,0]);
Corey Alix
  • 2,694
  • 2
  • 27
  • 38
  • 1
    I'm looking through the documentation of `proj4` and I don't see anywhere that `new proj4("some string")` is called. I don't think it's necessary by looking at [the source](https://github.com/proj4js/proj4js/blob/master/lib/core.js) either. You can define `proj4` as a function and then create a `proj4` module with the other functions like `defs` and `transform`. – David Sherret Apr 20 '15 at 15:31
  • Removed constructor. Can you demonstrate? https://gist.github.com/ca0v/2e3da4ce0c7178f102f1 – Corey Alix Apr 20 '15 at 15:56
  • Now its, $ npm install --save @types/proj4 – oCcSking May 11 '23 at 14:27

1 Answers1

1

Are you looking for something like below? When you declare a function and a Module with the same name (the function needs the be declared before the module or you will get an error) they merge.

Below is the code you had with some small changes (and I removed some functions).

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);
Dick van den Brink
  • 13,690
  • 3
  • 32
  • 43