admin管理员组

文章数量:1323497

I'm trying to create typings definitions for already existed library, and having issues describe its structure properly. The problem is nested namespaces. In JavaScript full name of my method looks like this:

NameSpace1.NameSpace2.NameSpace3.MethodName()

But I'm not able to create proper d.ts definition file... I've tried different binations, with export interface, export module for nested namespaces... But nothing works. The only construction that does not fire any errors is following:

declare namespace NameSpace1 {
}

But this is not enough... Do you know how to properly describe such a nested namespaces in TypeScript definitions?

I'm trying to create typings definitions for already existed library, and having issues describe its structure properly. The problem is nested namespaces. In JavaScript full name of my method looks like this:

NameSpace1.NameSpace2.NameSpace3.MethodName()

But I'm not able to create proper d.ts definition file... I've tried different binations, with export interface, export module for nested namespaces... But nothing works. The only construction that does not fire any errors is following:

declare namespace NameSpace1 {
}

But this is not enough... Do you know how to properly describe such a nested namespaces in TypeScript definitions?

Share asked Aug 1, 2016 at 19:43 shytikovshytikov 9,5689 gold badges61 silver badges105 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6
declare namespace NameSpace1.NameSpace2.NameSpace3 {
  function MethodName(): void;
}

There are literally thousands of examples of how to write definition files at https://github./DefinitelyTyped/DefinitelyTyped ; I'd remend looking for something similar to what you have next time you're stuck.

本文标签: javascriptCreate typings for nested namespaces in typescriptStack Overflow