Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript 0.9: module functions

Tags:

typescript

It seems that you can't do this anymore in TypeScript 0.9:

declare module "mymodule" {
    export function(): any;
}

Is there a way of creating typings that allow to call the exported module in 0.9?

Notice that the exported function doesn't have a name. That's the way to declare callable modules in previous versions of typescript, because there are a lot of node modules exporting just a function.

like image 817
soywiz Avatar asked May 05 '13 16:05

soywiz


1 Answers

The change appears deliberate, and there is no longer a way to do that:

The ‘module’ keyword no longer creates a type

Description: In 0.9.0, a clearer distinction is made between roles of namespaces, types, and values. Modules now contribute only to namespaces and values and will no longer contribute a type. 
Reason: This simplification of the role of modules allow modules to now extend classes and functions more easily.

From: http://blogs.msdn.com/b/typescript/archive/2013/04/22/announcing-0-9-early-previews.aspx

like image 191
Jude Fisher Avatar answered Oct 04 '22 12:10

Jude Fisher