diff options
author | 2022-02-07 22:02:54 -0800 | |
---|---|---|
committer | 2022-02-07 22:02:54 -0800 | |
commit | a571c56b4ca9266302483e36460b3f830e23c0d7 (patch) | |
tree | bb3ee5868d16de9a1c96828bd3ae092dacfb571b /integration/bunjs-only-snippets/transpiler.test.js | |
parent | 7b5bf62ad581292395ebed37d705ddd892a9a812 (diff) | |
download | bun-a571c56b4ca9266302483e36460b3f830e23c0d7.tar.gz bun-a571c56b4ca9266302483e36460b3f830e23c0d7.tar.zst bun-a571c56b4ca9266302483e36460b3f830e23c0d7.zip |
[TS] Implement `import {type foo} from 'bar';` (type inside clause)
Diffstat (limited to 'integration/bunjs-only-snippets/transpiler.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/transpiler.test.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js index 310546e83..167032c9a 100644 --- a/integration/bunjs-only-snippets/transpiler.test.js +++ b/integration/bunjs-only-snippets/transpiler.test.js @@ -16,6 +16,18 @@ describe("Bun.Transpiler", () => { const code = `import { useParams } from "remix"; import type { LoaderFunction, ActionFunction } from "remix"; + import { type xx } from 'mod'; + import { type xx as yy } from 'mod'; + import { type 'xx' as yy } from 'mod'; + import { type as } from 'mod'; + import { type as as } from 'mod'; + import { type as as as } from 'mod'; + import { type xx } from 'mod'; + import { type xx as yy } from 'mod'; + import { type if as yy } from 'mod'; + import { type 'xx' as yy } from 'mod'; + import React, { type ReactNode } from 'react'; + export const loader: LoaderFunction = async ({ params @@ -40,6 +52,8 @@ describe("Bun.Transpiler", () => { it("reports import paths, excluding types", () => { const imports = transpiler.scanImports(code); expect(imports.filter(({ path }) => path === "remix")).toHaveLength(1); + expect(imports.filter(({ path }) => path === "mod")).toHaveLength(0); + expect(imports.filter(({ path }) => path === "react")).toHaveLength(1); }); }); @@ -123,12 +137,20 @@ describe("Bun.Transpiler", () => { }); it("removes types", () => { + expect(code.includes("mod")).toBe(true); + expect(code.includes("xx")).toBe(true); expect(code.includes("ActionFunction")).toBe(true); expect(code.includes("LoaderFunction")).toBe(true); + expect(code.includes("ReactNode")).toBe(true); + expect(code.includes("React")).toBe(true); const out = transpiler.transformSync(code); expect(out.includes("ActionFunction")).toBe(false); expect(out.includes("LoaderFunction")).toBe(false); + expect(out.includes("mod")).toBe(false); + expect(out.includes("xx")).toBe(false); + expect(out.includes("ReactNode")).toBe(false); + expect(out.includes("React")).toBe(true); const { exports } = transpiler.scan(out); expect(exports[0]).toBe("action"); |