diff --git a/src/utils/typescript.ts b/src/utils/typescript.ts index 09b0af1df..6cb19c26b 100644 --- a/src/utils/typescript.ts +++ b/src/utils/typescript.ts @@ -27,6 +27,9 @@ export const tryToRegisterTsNode = (): void => { skipProject: JSON.parse(skipProjectRaw), transpileOnly: JSON.parse(transpileOnlyRaw), swc: JSON.parse(swcRaw), + compilerOptions: { + allowJs: true, + }, }); } catch (err) { const params = `swc: "${swcRaw}", transpileOnly: "${transpileOnlyRaw}", skipProject: "${skipProjectRaw}"`; diff --git a/test/src/utils/typescript.ts b/test/src/utils/typescript.ts index 282505ef8..fc78e4e1e 100644 --- a/test/src/utils/typescript.ts +++ b/test/src/utils/typescript.ts @@ -33,6 +33,19 @@ describe("utils/typescript", () => { assert.notCalled(registerStub); }); + it("should pass 'allowJs' option", () => { + ts.tryToRegisterTsNode(); + + assert.calledOnceWith( + registerStub, + sinon.match({ + compilerOptions: { + allowJs: true, + }, + }), + ); + }); + it("should respect env vars", () => { process.env.TS_NODE_SKIP_PROJECT = "false"; process.env.TS_NODE_TRANSPILE_ONLY = "false";