Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Jun 18, 2019
1 parent 29c262e commit c0d8c19
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/transformers/declarations.ts
Expand Up @@ -1054,7 +1054,7 @@ namespace ts {
});
const namespaceDecl = createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name!, createModuleBlock(declarations), NodeFlags.Namespace);

if (!hasModifier(clean, ModifierFlags.ExportDefault)) {
if (!hasModifier(clean, ModifierFlags.Default)) {
return [clean, namespaceDecl];
}

Expand Down
Expand Up @@ -18,7 +18,19 @@ Example.Foo = Foo
export class Bar {}
export default function Example() {}

Example.Bar = Bar
Example.Bar = Bar

//// [index4.ts]
function A() { }

function B() { }

export function C() {
return null;
}

C.A = A;
C.B = B;

//// [foo.js]
"use strict";
Expand Down Expand Up @@ -56,6 +68,17 @@ exports.Bar = Bar;
function Example() { }
exports["default"] = Example;
Example.Bar = Bar;
//// [index4.js]
"use strict";
exports.__esModule = true;
function A() { }
function B() { }
function C() {
return null;
}
exports.C = C;
C.A = A;
C.B = B;


//// [foo.d.ts]
Expand Down Expand Up @@ -83,3 +106,9 @@ declare namespace Example {
var Bar: typeof import("./index3").Bar;
}
export default Example;
//// [index4.d.ts]
export declare function C(): any;
export declare namespace C {
var A: () => void;
var B: () => void;
}
Expand Up @@ -44,3 +44,28 @@ Example.Bar = Bar
>Bar : Symbol(Example.Bar, Decl(index3.ts, 1, 36))
>Bar : Symbol(Bar, Decl(index3.ts, 0, 0))

=== tests/cases/compiler/index4.ts ===
function A() { }
>A : Symbol(A, Decl(index4.ts, 0, 0))

function B() { }
>B : Symbol(B, Decl(index4.ts, 0, 17))

export function C() {
>C : Symbol(C, Decl(index4.ts, 2, 16), Decl(index4.ts, 6, 1))

return null;
}

C.A = A;
>C.A : Symbol(C.A, Decl(index4.ts, 6, 1))
>C : Symbol(C, Decl(index4.ts, 2, 16), Decl(index4.ts, 6, 1))
>A : Symbol(C.A, Decl(index4.ts, 6, 1))
>A : Symbol(A, Decl(index4.ts, 0, 0))

C.B = B;
>C.B : Symbol(C.B, Decl(index4.ts, 8, 8))
>C : Symbol(C, Decl(index4.ts, 2, 16), Decl(index4.ts, 6, 1))
>B : Symbol(C.B, Decl(index4.ts, 8, 8))
>B : Symbol(B, Decl(index4.ts, 0, 17))

Expand Up @@ -47,3 +47,31 @@ Example.Bar = Bar
>Bar : typeof Bar
>Bar : typeof Bar

=== tests/cases/compiler/index4.ts ===
function A() { }
>A : () => void

function B() { }
>B : () => void

export function C() {
>C : typeof C

return null;
>null : null
}

C.A = A;
>C.A = A : () => void
>C.A : () => void
>C : typeof C
>A : () => void
>A : () => void

C.B = B;
>C.B = B : () => void
>C.B : () => void
>C : typeof C
>B : () => void
>B : () => void

Expand Up @@ -17,4 +17,16 @@ Example.Foo = Foo
export class Bar {}
export default function Example() {}

Example.Bar = Bar
Example.Bar = Bar

// @filename: index4.ts
function A() { }

function B() { }

export function C() {
return null;
}

C.A = A;
C.B = B;

0 comments on commit c0d8c19

Please sign in to comment.