0xDECAFBAD 0xDECAFBAD - 2 months ago 30
TypeScript Question

TypeScript Declaration File: Function in namespace

I am using OpenLayers 3 in one of my projects and retrieved the TypeScript defintion file from DefinitelyTyped (Definition File), but some functions are missing, which I have to manually add in the declaration file. One of them is the

ol.inherits
-functions (OpenLayers 3 API Reference).

I am struggeling defining this function, as the ol keyword is used as namespace identifier and I am not able to put a function directly in the namespace.

I also tried to add something like this, but obviously it says Duplicate identifier.

interface olStatic {
inherits(childCtor: () => any, parentCtor: () => any);
}
declare var ol: olStatic;

Answer

I have made my own definition file for ol3. I am not sure whether this helps but in my own file I do define the ol.inherits like so:

declare module ol {

function inherits(arg1:any, arg2:any);
 ........................
export class Collection<T> {
............................