Skip to content

Commit

Permalink
fix(namespace): same import in multiple namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jtassin committed Dec 15, 2020
1 parent f724dea commit 9f69855
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions test/namespace-export.test.ts
Expand Up @@ -149,3 +149,70 @@ test("Handles namespace exports. #3", async (t, {typescript}) => {
} = bundle;
t.deepEqual(formatCode(file.code), formatCode(`export * as Foo from "ava";`));
});

test("Handles namespace exports. #4", async (t, {typescript}) => {
if (lt(typescript.version, "3.8.0")) {
t.pass(`Current TypeScript version (${typescript.version} does not support 'export * as Foo from "..."' syntax. Skipping...`);
return;
}

const bundle = await generateRollupBundle(
[
{
entry: true,
fileName: "index.ts",
text: `\
export * as Foo from "./foo";
export * as Bar from "./bar";
`
},
{
entry: false,
fileName: "foo.ts",
text: `\
import { Subscribable } from 'ava';
export interface Foo extends Subscribable {
a: number
}
`
},
{
entry: false,
fileName: "bar.ts",
text: `\
import { Subscribable } from 'ava';
export interface Bar extends Subscribable {
b: number;
}
`
}
],
{
typescript,
debug: false
}
);
const {
declarations: [file]
} = bundle;
t.deepEqual(
formatCode(file.code),
formatCode(`\
import { Subscribable } from "ava";
declare namespace Foo {
interface Foo extends Subscribable {
a: number;
}
}
declare namespace Bar {
interface Bar extends Subscribable {
b: number;
}
}
export { Foo, Bar };
`)
);
});

0 comments on commit 9f69855

Please sign in to comment.