Back to typescript-generator Wiki
version 1.6.171 and above
TypeScript language offers different ways how to organize declarations and code. In addition to global scope, declarations can also be organized using modules and namespaces. Following parameters controls what kind of output will be generated.
declarationFile
(.d.ts) or implementationFile
(.ts).declarationFile
.
global
, module
or ambientModule
.global
means that declarations will be in global scope or namespace (no module).module
means that generated file will contain top-level export
declarations.ambientModule
means that generated declarations will be wrapped in declare module "mod" { }
declaration.outputKind
is set to ambientModule
.
export as namespace
declaration is generated).outputKind
is set to module
.
Table bellow shows output variants by examples. Primarily typescript-generator produces declaration files (left column) but it can be also configured to produce implementation files (right column). Table also contains info how to configure typescript-generator to produce particular variant. Keywords commented out are optional and typescript-generator doesn't emit them.
declaration file (.d.ts) | implementation file (.ts) | ||
---|---|---|---|
global |
outputKind = global
|
outputFileType = implementationFile
outputKind = global
|
|
|
|
||
global with namespace |
outputKind = global
namespace = "NS"
|
outputFileType = implementationFile
outputKind = global
namespace = "NS"
|
|
|
|
||
module |
outputKind = ambientModule
module = "mod"
|
outputKind = module
|
outputFileType = implementationFile
outputKind = module
|
|
|
|
|
module with namespace |
outputKind = ambientModule
module = "mod"
namespace = "NS"
|
outputKind = module
namespace = "NS"
|
outputFileType = implementationFile
outputKind = module
namespace = "NS"
|
|
|
|