Since TypeScript 0.9, you can set the exported value of an module directly using export =
:
// client.ts
class Client {
constructor(public name: string, public description: string) { }
}
export = Client;
Is there a way to reference Client
using a /// <reference ... />
?
The following does not expose the Client
class:
/// <reference path="./client.ts" />
class SomeClass {
addClient(client: Client) { // Could not find symbol 'Client'
...
}
}
I guess this is the expected behavior since I'm exporting a direct reference to the Client
class, so the module is basically anonymous. But in the above class I'm not actually instantiating a new Client
, so adding import Client = require('Client');
would let the AMD loader load client.js
even though it would not be needed if addClient
is never called.
So I was hoping for something like:
/// <reference path="./client.ts" export="Client" />
Where export
would be the name to assign the module to.