diff --git a/.gitignore b/.gitignore index b2cd458..14326bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules/ -test/ts*/ +baselines/local/ diff --git a/baselines/ts3.4/src/test.d.ts b/baselines/reference/ts3.4/src/test.d.ts similarity index 100% rename from baselines/ts3.4/src/test.d.ts rename to baselines/reference/ts3.4/src/test.d.ts diff --git a/baselines/ts3.4/test.d.ts b/baselines/reference/ts3.4/test.d.ts similarity index 100% rename from baselines/ts3.4/test.d.ts rename to baselines/reference/ts3.4/test.d.ts diff --git a/baselines/ts3.5/src/test.d.ts b/baselines/reference/ts3.5/src/test.d.ts similarity index 100% rename from baselines/ts3.5/src/test.d.ts rename to baselines/reference/ts3.5/src/test.d.ts diff --git a/baselines/ts3.5/test.d.ts b/baselines/reference/ts3.5/test.d.ts similarity index 88% rename from baselines/ts3.5/test.d.ts rename to baselines/reference/ts3.5/test.d.ts index 889c7b3..4430e8b 100644 --- a/baselines/ts3.5/test.d.ts +++ b/baselines/reference/ts3.5/test.d.ts @@ -23,7 +23,7 @@ export namespace N { import { C as CD } from "./src/test"; import * as rex_1 from "./src/test"; //another comment -export { rex_1 as rex } from "./src/test"; +export { rex_1 as rex }; export interface E { a: number; b: number; @@ -48,3 +48,5 @@ type J = [ /*bar*/ number, /*arr*/ ...boolean[] ]; +import * as default_1 from "./src/test"; +export { default_1 as default }; diff --git a/baselines/ts3.6/src/test.d.ts b/baselines/reference/ts3.6/src/test.d.ts similarity index 100% rename from baselines/ts3.6/src/test.d.ts rename to baselines/reference/ts3.6/src/test.d.ts diff --git a/baselines/ts3.6/test.d.ts b/baselines/reference/ts3.6/test.d.ts similarity index 89% rename from baselines/ts3.6/test.d.ts rename to baselines/reference/ts3.6/test.d.ts index 41894c0..a67db23 100644 --- a/baselines/ts3.6/test.d.ts +++ b/baselines/reference/ts3.6/test.d.ts @@ -25,7 +25,7 @@ export namespace N { import { C as CD } from "./src/test"; import * as rex_1 from "./src/test"; //another comment -export { rex_1 as rex } from "./src/test"; +export { rex_1 as rex }; export interface E { a: number; b: number; @@ -50,3 +50,5 @@ type J = [ /*bar*/ number, /*arr*/ ...boolean[] ]; +import * as default_1 from "./src/test"; +export { default_1 as default }; diff --git a/baselines/ts3.7/src/test.d.ts b/baselines/reference/ts3.7/src/test.d.ts similarity index 100% rename from baselines/ts3.7/src/test.d.ts rename to baselines/reference/ts3.7/src/test.d.ts diff --git a/baselines/ts3.7/test.d.ts b/baselines/reference/ts3.7/test.d.ts similarity index 89% rename from baselines/ts3.7/test.d.ts rename to baselines/reference/ts3.7/test.d.ts index 0db2ff2..7c5a6ee 100644 --- a/baselines/ts3.7/test.d.ts +++ b/baselines/reference/ts3.7/test.d.ts @@ -25,7 +25,7 @@ export namespace N { import { C as CD } from "./src/test"; import * as rex_1 from "./src/test"; //another comment -export { rex_1 as rex } from "./src/test"; +export { rex_1 as rex }; export interface E { a: number; b: number; @@ -50,3 +50,5 @@ type J = [ /*bar*/ number, /*arr*/ ...boolean[] ]; +import * as default_1 from "./src/test"; +export { default_1 as default }; diff --git a/baselines/ts3.8/src/test.d.ts b/baselines/reference/ts3.8/src/test.d.ts similarity index 100% rename from baselines/ts3.8/src/test.d.ts rename to baselines/reference/ts3.8/src/test.d.ts diff --git a/baselines/ts3.9/test.d.ts b/baselines/reference/ts3.8/test.d.ts similarity index 93% rename from baselines/ts3.9/test.d.ts rename to baselines/reference/ts3.8/test.d.ts index 068b32a..78a6446 100644 --- a/baselines/ts3.9/test.d.ts +++ b/baselines/reference/ts3.8/test.d.ts @@ -49,3 +49,4 @@ type J = [ /*bar*/ number, /*arr*/ ...boolean[] ]; +export * as default from "./src/test"; diff --git a/baselines/ts3.9/src/test.d.ts b/baselines/reference/ts3.9/src/test.d.ts similarity index 100% rename from baselines/ts3.9/src/test.d.ts rename to baselines/reference/ts3.9/src/test.d.ts diff --git a/baselines/ts3.8/test.d.ts b/baselines/reference/ts3.9/test.d.ts similarity index 93% rename from baselines/ts3.8/test.d.ts rename to baselines/reference/ts3.9/test.d.ts index 068b32a..78a6446 100644 --- a/baselines/ts3.8/test.d.ts +++ b/baselines/reference/ts3.9/test.d.ts @@ -49,3 +49,4 @@ type J = [ /*bar*/ number, /*arr*/ ...boolean[] ]; +export * as default from "./src/test"; diff --git a/baselines/ts4.0/src/test.d.ts b/baselines/reference/ts4.0/src/test.d.ts similarity index 100% rename from baselines/ts4.0/src/test.d.ts rename to baselines/reference/ts4.0/src/test.d.ts diff --git a/baselines/ts4.0/test.d.ts b/baselines/reference/ts4.0/test.d.ts similarity index 93% rename from baselines/ts4.0/test.d.ts rename to baselines/reference/ts4.0/test.d.ts index 1899116..a1ad540 100644 --- a/baselines/ts4.0/test.d.ts +++ b/baselines/reference/ts4.0/test.d.ts @@ -49,3 +49,4 @@ type J = [ bar: number, ...arr: boolean[] ]; +export * as default from "./src/test"; diff --git a/baselines/reference/tsconfig.json b/baselines/reference/tsconfig.json new file mode 100644 index 0000000..26bb87e --- /dev/null +++ b/baselines/reference/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "strict": true, + "noEmit": true, + "target": "esnext", + "module": "commonjs", + }, + "files": [ + "test.d.ts", + "src/test.d.ts" + ] +} diff --git a/index.test.js b/index.test.js index f971648..24aaac6 100644 --- a/index.test.js +++ b/index.test.js @@ -6,25 +6,21 @@ const semver = require("semver"); describe("main", () => { const tsVersions = ["3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0"]; - afterEach(() => { - for (const tsVersion of tsVersions) { - if (fs.existsSync(`test/ts${tsVersion}`)) { - sh.rm("-r", `test/ts${tsVersion}`); - } - } - }); + if (fs.existsSync(`baselines/local`)) { + sh.rm("-r", `baselines/local`); + } for (const tsVersion of tsVersions) { test( "downlevel TS to " + tsVersion, () => { - main("test", `test/ts${tsVersion}`, semver.coerce(tsVersion)); + main("test", `baselines/local/ts${tsVersion}`, semver.coerce(tsVersion)); - expect(fs.readFileSync(`test/ts${tsVersion}/test.d.ts`, "utf8")).toEqual( - fs.readFileSync(`baselines/ts${tsVersion}/test.d.ts`, "utf8") + expect(fs.readFileSync(`baselines/local/ts${tsVersion}/test.d.ts`, "utf8")).toEqual( + fs.readFileSync(`baselines/reference/ts${tsVersion}/test.d.ts`, "utf8") ); - expect(fs.readFileSync(`test/ts${tsVersion}/src/test.d.ts`, "utf8")).toEqual( - fs.readFileSync(`baselines/ts${tsVersion}/src/test.d.ts`, "utf8") + expect(fs.readFileSync(`baselines/local/ts${tsVersion}/src/test.d.ts`, "utf8")).toEqual( + fs.readFileSync(`baselines/reference/ts${tsVersion}/src/test.d.ts`, "utf8") ); }, 10 * 1000 diff --git a/package.json b/package.json index a913717..946f543 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "bin": "index.js", "scripts": { "test": "jest", - "baseline-accept": "cp -r test/ts3.4 baselines" + "baseline-accept": "cp -r baselines/local/ts* baselines/reference" }, "author": "Nathan Shively-Sanders", "license": "MIT",