Skip to content

Commit 60d2e5f

Browse files
committed
test: check that emitDeclarationOnly works as expected
- should output declaration and declaration map for file - code + declaration should contain the one-line function - code _shouldn't_ contain anything from TS files - since this is plain ESM code, we don't need another plugin to process this - nice workaround to installing another plugin that I hadn't thought of till now!
1 parent 497b7f6 commit 60d2e5f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

__tests__/integration/no-errors.spec.ts

+26
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,29 @@ test("integration - no errors - no declarations", async () => {
6868
expect(output[0].fileName).toEqual("index.js");
6969
expect(output.length).toEqual(1); // no other files
7070
});
71+
72+
test("integration - no errors - allowJs + emitDeclarationOnly", async () => {
73+
const { output } = await helpers.genBundle({
74+
input: local("fixtures/no-errors/some-js-import.js"),
75+
tsconfig: local("fixtures/no-errors/tsconfig.json"),
76+
cacheRoot,
77+
extraOpts: {
78+
include: ["**/*.js"],
79+
tsconfigOverride: {
80+
compilerOptions: {
81+
allowJs: true,
82+
emitDeclarationOnly: true,
83+
},
84+
},
85+
},
86+
});
87+
88+
expect(output[0].fileName).toEqual("index.js");
89+
expect(output[1].fileName).toEqual("some-js-import.d.ts");
90+
expect(output[2].fileName).toEqual("some-js-import.d.ts.map");
91+
expect(output.length).toEqual(3); // no other files
92+
93+
expect(output[0].code).toEqual(expect.stringContaining("identity"));
94+
expect(output[0].code).not.toEqual(expect.stringContaining("sum")); // no TS files included
95+
expect("source" in output[1] && output[1].source!).toEqual(expect.stringContaining("identity"));
96+
});

0 commit comments

Comments
 (0)