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

Ability to override compiler options without specifying tsconfig #645

Closed
hellosmithy opened this issue Jul 31, 2018 · 1 comment
Closed

Comments

@hellosmithy
Copy link

  • Issue

Previously this module supported an inline tsconfig via __TS_CONFIG__. Now the only way to specify a custom override for module: 'commonjs' (which is a common use case for jest / typescript projects) is to provide a custom tsconfig file via tsConfigFile.

My use case is that I'm breaking out my jest config into a preset and as it shouldn't have any knowledge of the tsconfig for the consuming code, I want to be able to fallback to the defaultTSConfigFile as per

ts-jest/src/utils.ts

Lines 90 to 103 in f71f85e

function getTSConfigPathFromConfig(globals: ConfigGlobals): string {
const defaultTSConfigFile = getPathToClosestTSConfig();
if (!globals) {
return defaultTSConfigFile;
}
const tsJestConfig = getTSJestConfig(globals);
if (tsJestConfig.tsConfigFile) {
return tsJestConfig.tsConfigFile;
}
return defaultTSConfigFile;
}
but just override the compiler module settings as you might do via the command line with the --module flag.

  • Expected behavior

Ability to add compiler option overrides without specifying a custom tsconfig file https://www.typescriptlang.org/docs/handbook/compiler-options.html

For example:

"ts-jest": {
    "compilerOptions": {
        "module": "commonjs"
    }
}

Which could be deep merged into the settings found in defaultTSConfigFile.

I'm happy to submit a PR if the suggestion is acceptable.

  • Output from your debug log
    n/a

  • Link to a minimal repo that reproduces this issue

n/a

  • Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo

n/a

@huafu
Copy link
Collaborator

huafu commented Sep 2, 2018

@hellosmithy you can try the beta version (see #697) which allow you to define some inline options in the jest config: https://github.com/kulshekhar/ts-jest/tree/beta#typescript-configuration

@huafu huafu added this to the v23.10.0 milestone Sep 19, 2018
@huafu huafu closed this as completed Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants