Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't run karma.conf.js through TS when "allowJs": true #3529

Closed
webmaster128 opened this issue May 31, 2020 · 2 comments
Closed

Don't run karma.conf.js through TS when "allowJs": true #3529

webmaster128 opened this issue May 31, 2020 · 2 comments

Comments

@webmaster128
Copy link
Contributor

webmaster128 commented May 31, 2020

I have a project with "allowJs": true in tsconfig.json where I get errors like this:

31 05 2020 15:49:10.978:ERROR [config]: Error in config file!
  TypeError: karma.conf.js: Emit skipped
    at getOutput (/project/node_modules/ts-node/src/index.ts:560:17)
    at Object.compile (/project/node_modules/ts-node/src/index.ts:762:32)
    at Module.m._compile (/project/node_modules/ts-node/src/index.ts:841:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Object.require.extensions.<computed> [as .js] (/project/node_modules/ts-node/src/index.ts:844:12)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.parseConfig (/project/node_modules/karma/lib/config.js:358:22)

This unexpected behaviour here is that karma.conf.js is interpreted by ts-node. The explanation for this behaviour is here:

TypeScript Node works by registering the TypeScript compiler for .tsx? and .jsx? (when allowJs == true) extensions.

from https://github.com/TypeStrong/ts-node#how-it-works, which is used by require('ts-node').register() in Karma's lib/config.js.

I think only .ts config files should be handled by ts-node.

@devoto13
Copy link
Collaborator

This looks like a duplicate of #3329.

@devoto13
Copy link
Collaborator

devoto13 commented Feb 3, 2021

I'll close this in favour of #3329 which has more discussions.

@devoto13 devoto13 closed this as completed Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants