mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-26 12:43:48 -06:00
Merge pull request #3545 from Microsoft/emitNamespaces
Emit declarations of namespaces correctly
This commit is contained in:
commit
6db4faf488
@ -369,7 +369,7 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
|
||||
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
|
||||
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
|
||||
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"');
|
||||
definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
|
||||
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
|
||||
});
|
||||
|
||||
|
||||
@ -709,7 +709,12 @@ namespace ts {
|
||||
function writeModuleDeclaration(node: ModuleDeclaration) {
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
write("module ");
|
||||
if (node.flags & NodeFlags.Namespace) {
|
||||
write("namespace ");
|
||||
}
|
||||
else {
|
||||
write("module ");
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
while (node.body.kind !== SyntaxKind.ModuleBlock) {
|
||||
node = <ModuleDeclaration>node.body;
|
||||
|
||||
22
tests/baselines/reference/namespacesDeclaration.js
Normal file
22
tests/baselines/reference/namespacesDeclaration.js
Normal file
@ -0,0 +1,22 @@
|
||||
//// [namespacesDeclaration.ts]
|
||||
|
||||
module M {
|
||||
export namespace N {
|
||||
export module M2 {
|
||||
export interface I {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [namespacesDeclaration.js]
|
||||
|
||||
|
||||
//// [namespacesDeclaration.d.ts]
|
||||
declare module M {
|
||||
namespace N {
|
||||
module M2 {
|
||||
interface I {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
tests/baselines/reference/namespacesDeclaration.symbols
Normal file
16
tests/baselines/reference/namespacesDeclaration.symbols
Normal file
@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/namespacesDeclaration.ts ===
|
||||
|
||||
module M {
|
||||
>M : Symbol(M, Decl(namespacesDeclaration.ts, 0, 0))
|
||||
|
||||
export namespace N {
|
||||
>N : Symbol(N, Decl(namespacesDeclaration.ts, 1, 10))
|
||||
|
||||
export module M2 {
|
||||
>M2 : Symbol(M2, Decl(namespacesDeclaration.ts, 2, 23))
|
||||
|
||||
export interface I {}
|
||||
>I : Symbol(I, Decl(namespacesDeclaration.ts, 3, 24))
|
||||
}
|
||||
}
|
||||
}
|
||||
16
tests/baselines/reference/namespacesDeclaration.types
Normal file
16
tests/baselines/reference/namespacesDeclaration.types
Normal file
@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/namespacesDeclaration.ts ===
|
||||
|
||||
module M {
|
||||
>M : any
|
||||
|
||||
export namespace N {
|
||||
>N : any
|
||||
|
||||
export module M2 {
|
||||
>M2 : any
|
||||
|
||||
export interface I {}
|
||||
>I : I
|
||||
}
|
||||
}
|
||||
}
|
||||
9
tests/cases/compiler/namespacesDeclaration.ts
Normal file
9
tests/cases/compiler/namespacesDeclaration.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// @declaration: true
|
||||
|
||||
module M {
|
||||
export namespace N {
|
||||
export module M2 {
|
||||
export interface I {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user