ts-jest icon indicating copy to clipboard operation
ts-jest copied to clipboard

[Feature]: rename isolatedModules

Open joshuambg opened this issue 2 years ago • 7 comments

🚀 Feature Proposal

Typescript has a config option named isolatedModules https://www.typescriptlang.org/tsconfig#isolatedModules

ts-jest also has a config option named isolatedModules https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules

This is extremely confusing. Please rename your config option if it is not related to the tsconfig option. (If they are related in some way, you need to update the documentation and better explain how they interact. That is not satisfied with comments in this issue. Update the docs. )

Motivation

Better explain config options.

Example

No response

joshuambg avatar Aug 10 '22 20:08 joshuambg

I agree, this was confusing to me too. I suggest renaming it to transpileOnly, inspired by this issue: https://github.com/microsoft/TypeScript/issues/29651 Right now the presence of isolatedModules in ts-jest's config implies that the project must be isolatedModules=true-compatible, but it does more than that under the hood.

It could also be more than a boolean option, later allowing specifying swc and esbuild.

The documentation could also recommend setting isolatedModules to true in tsconfig.json, as to make sure that no incompatible features are used. A runtime warning would be even better.

alecmev avatar Aug 28 '22 11:08 alecmev

Well, I think possibly the doc authors are confused about what isolatedModules does in TypeScript. Setting isolatedModules: true for ts-jest options does not do what the docs suggest that it does. Specifically, it says, "You'll lose type-checking ability" which is what transpileOnly does in tsconfig.json. But if you set isolatedModules: true for ts-jest, it still type-checks! So maybe it is just setting the tsconfig option, and they're just confused about what it does?

matthew-dean avatar Oct 31 '22 17:10 matthew-dean

Enable isolatedModules in tsconfig has no effect on what ts-jest does internally.

Indeed the option isolatedModules of ts-jest config is identical to transpilation mode like ts-node.

Because both of the options have the same name which causes confusion.

ahnpnl avatar Oct 31 '22 18:10 ahnpnl

ts-loader has a transpileOnly option which works as expected and is separate from isolatedModules.

https://github.com/TypeStrong/ts-loader#transpileonly

If ts-jest had the same option, it would be convenient to separate bundling, testing, and type checking as 3 separate parallel CI tasks to reduce total time to finish CI.

jdufresne avatar Apr 04 '23 15:04 jdufresne

is it even possible to only typecheck in ts-jest ?

zargham-leanix avatar Jun 24 '23 01:06 zargham-leanix

is it even possible to only typecheck in ts-jest ?

You missed the point. @jdufresne was presumably saying that by using a transpileOnly mode in ts-jest, we can avoid ts-jest doing superfluous type checks of its own. That task can be split off to a dedicated type-checking thread that has nothing to do with unit testing.

bfricka avatar Aug 28 '23 21:08 bfricka