-
Notifications
You must be signed in to change notification settings - Fork 27k
Closed
Description
When generating .d.ts file it is sometimes nice to be able to export a class as non-instantiable. Some classes are visible to the developer, but they are never meant to be instantiated by the developer, so we would like to hide their constructor.
assume class in source which needs to be exported:
class SomeType {
/**
* @private() // some way to mark a constructor as private.
*/
constructor(somePrivateDep:SomePrivateDep) {}
someMethod(): void {...}
}
When generating .d.ts we have two options:
- We can generate a class and hide a constructor:
declare class SomeType {
someMethod(): void {...}
}
- or we create an interface with an injectable ref.
interface PrivateConstructor {} // declared only once in .d.ts file
declare var SomeType: PrivateConstructor; // needed to make DI work properly
interface SomeType {
someMethod(): void {...}
}
I think we should do option no. 2, but either one is fine.
Metadata
Metadata
Assignees
Labels
No labels