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

TypeScript 3.4's tsBuildInfoFile option breaks ts-jest #1095

Closed
haines opened this issue May 10, 2019 · 5 comments · Fixed by #1096 or ryshu/enib-internships#113
Closed

TypeScript 3.4's tsBuildInfoFile option breaks ts-jest #1095

haines opened this issue May 10, 2019 · 5 comments · Fixed by #1096 or ryshu/enib-internships#113

Comments

@haines
Copy link
Contributor

haines commented May 10, 2019

Issue :

Typescript 3.4 introduces .tsbuildinfo files for incremental compilation, and the tsBuildInfoFile compiler option to customize the location of the generated files.

The presence of this option in tsconfig.json causes ts-jest to abort with the following error:

error TS5069: Option 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or option 'composite'.

This happens even though composite is true in tsconfig.json

Expected behavior :

ts-jest doesn't abort with tsconfig that includes { composite: true, tsBuildInfoFile: "path/to/tsbuildinfo" }.

Debug log:

log file content
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"24.0.2"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2019-05-10T13:17:41.452Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"24.0.2"},"message":"creating Importer singleton","sequence":2,"time":"2019-05-10T13:17:43.804Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"24.0.2"},"message":"creating jest presets not handling JavaScript files","sequence":3,"time":"2019-05-10T13:17:43.812Z"}
{"context":{"actualVersion":"24.8.0","expectedVersion":">=24 <25","logLevel":20,"namespace":"versions","package":"ts-jest","version":"24.0.2"},"message":"checking version of jest: OK","sequence":4,"time":"2019-05-10T13:17:43.813Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"created new transformer","sequence":5,"time":"2019-05-10T13:17:43.814Z"}
{"context":{"fileName":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/private/var/folders/nl/618fj9w97b7gglgh3bx3w_tw0000gn/T/jest_dx","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":null,"globalTeardown":null,"globals":{"ts-jest":{"isolatedModules":true}},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"60cab36cfe4f54daad44707695fc2cd5","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro","roots":["/Users/haines/work/ts-jest-tsbuildinfo-bug-repro"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":["/node_modules/"],"testRegex":["\\.test\\.ts$"],"testRunner":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro"},"transformerId":1,"version":"24.0.2"},"message":"computing cache key for /Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts","sequence":6,"time":"2019-05-10T13:17:43.814Z"}
{"context":{"logLevel":30,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"no matching config-set found, creating a new one","sequence":7,"time":"2019-05-10T13:17:43.815Z"}
{"context":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/private/var/folders/nl/618fj9w97b7gglgh3bx3w_tw0000gn/T/jest_dx","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":null,"globalTeardown":null,"globals":{"ts-jest":{"isolatedModules":true}},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"60cab36cfe4f54daad44707695fc2cd5","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro","roots":["/Users/haines/work/ts-jest-tsbuildinfo-bug-repro"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":["/node_modules/"],"testRegex":["\\.test\\.ts$"],"testRunner":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"backports","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"backporting config","sequence":8,"time":"2019-05-10T13:17:43.815Z"}
{"context":{"jestConfig":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/private/var/folders/nl/618fj9w97b7gglgh3bx3w_tw0000gn/T/jest_dx","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":null,"globalTeardown":null,"globals":{"ts-jest":{"isolatedModules":true}},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"60cab36cfe4f54daad44707695fc2cd5","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro","roots":["/Users/haines/work/ts-jest-tsbuildinfo-bug-repro"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":["/node_modules/"],"testRegex":["\\.test\\.ts$"],"testRunner":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"normalized jest config","sequence":9,"time":"2019-05-10T13:17:43.815Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsJestConfig":{"compiler":"typescript","diagnostics":{"ignoreCodes":[6059,18002,18003],"pretty":true,"throws":true},"isolatedModules":true,"packageJson":{"kind":"file"},"transformers":[],"tsConfig":{"kind":"file"}},"version":"24.0.2"},"message":"normalized ts-jest config","sequence":10,"time":"2019-05-10T13:17:43.816Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"babel is disabled","sequence":11,"time":"2019-05-10T13:17:43.819Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","requireResult":{"exists":true,"given":"typescript","path":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/node_modules/typescript/lib/typescript.js"},"version":"24.0.2"},"message":"loaded module typescript","sequence":12,"time":"2019-05-10T13:17:44.003Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"24.0.2"},"message":"patching typescript","sequence":13,"time":"2019-05-10T13:17:44.003Z"}
{"context":{"actualVersion":"3.4.5","expectedVersion":">=2.7 <4","logLevel":20,"namespace":"versions","package":"ts-jest","version":"24.0.2"},"message":"checking version of typescript: OK","sequence":14,"time":"2019-05-10T13:17:44.004Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsConfigFileName":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/tsconfig.json","version":"24.0.2"},"message":"readTsConfig(): reading /Users/haines/work/ts-jest-tsbuildinfo-bug-repro/tsconfig.json","sequence":15,"time":"2019-05-10T13:17:44.004Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsconfig":{"input":{"compilerOptions":{"composite":true,"esModuleInterop":true,"moduleResolution":"node","outDir":"build","strict":true,"target":"ES2018","tsBuildInfoFile":"build/.tsbuildinfo"}},"resolved":{"compileOnSave":false,"configFileSpecs":{"excludeSpecs":["build"],"includeSpecs":["**/*"],"validatedExcludeSpecs":["build"],"validatedIncludeSpecs":["**/*"],"wildcardDirectories":{"/users/haines/work/ts-jest-tsbuildinfo-bug-repro":1}},"errors":[],"fileNames":["/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts"],"options":{"configFilePath":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/tsconfig.json","declaration":false,"esModuleInterop":true,"inlineSourceMap":false,"inlineSources":true,"module":1,"moduleResolution":2,"noEmit":false,"outDir":"$$ts-jest$$","removeComments":false,"sourceMap":true,"strict":true,"target":5,"tsBuildInfoFile":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/build/.tsbuildinfo"},"raw":{"compileOnSave":false,"compilerOptions":{"composite":true,"esModuleInterop":true,"moduleResolution":"node","outDir":"build","strict":true,"target":"ES2018","tsBuildInfoFile":"build/.tsbuildinfo"}},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{"/users/haines/work/ts-jest-tsbuildinfo-bug-repro":1}}},"version":"24.0.2"},"message":"normalized typescript config","sequence":16,"time":"2019-05-10T13:17:44.018Z"}
{"context":{"fileName":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"instrument":false},"transformerId":1,"version":"24.0.2"},"message":"processing /Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts","sequence":17,"time":"2019-05-10T13:17:44.019Z"}
{"context":{"logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"creating typescript compiler (isolated modules)","sequence":18,"time":"2019-05-10T13:17:44.020Z"}
{"context":{"cacheDirectory":"/private/var/folders/nl/618fj9w97b7gglgh3bx3w_tw0000gn/T/jest_dx/ts-jest/e3/88a1ed254bf5e0c734309dae3399e13f9f492f","logLevel":20,"namespace":"config","package":"ts-jest","version":"24.0.2"},"message":"will use file caching","sequence":19,"time":"2019-05-10T13:17:44.020Z"}
{"context":{"fileName":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts","logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"readThrough(): cache miss","sequence":20,"time":"2019-05-10T13:17:44.021Z"}
{"context":{"fileName":"/Users/haines/work/ts-jest-tsbuildinfo-bug-repro/index.test.ts","logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"getOutput(): compiling as isolated module","sequence":21,"time":"2019-05-10T13:17:44.021Z"}
{"context":{"call":null,"logLevel":20,"namespace":"ts-hoisting","package":"ts-jest","transformerId":1,"version":"24.0.2"},"message":"visitSourceFileNode(): hoisting","sequence":22,"time":"2019-05-10T13:17:44.061Z"}
{"context":{"diagnosticCodes":[5069],"diagnosticText":"\u001b[91merror\u001b[0m\u001b[90m TS5069: \u001b[0mOption 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or option 'composite'.\n","logLevel":20,"namespace":"TSError","package":"ts-jest","version":"24.0.2"},"message":"created new TSError","sequence":23,"time":"2019-05-10T13:17:44.091Z"}

Minimal repo :

https://github.com/haines/ts-jest-tsbuildinfo-bug-repro

https://travis-ci.org/haines/ts-jest-tsbuildinfo-bug-repro

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 10, 2019

Based on the error message, it means also that specifying incremental: true with tsBuildInforFile will result in the same error ?

@haines
Copy link
Contributor Author

haines commented May 10, 2019

I think specifying incremental: true actually would not cause the same error because it is not cleared the way composite is here

@nullxone
Copy link

nullxone commented May 20, 2019

Hi. I've gotten this working with typescripts project reference set up. It works just fine.

Thanks, this project helped me resolve the issue where jest was picking up renamed and old files from the tsc --watch build because tsc -w doesnt delete deleted files. It's also super neat to have type errors with the rest!

Per https://www.typescriptlang.org/docs/handbook/project-references.html
Referenced projects must have the new composite setting enabled.

Per linked repo, the workspace tsconfig.json has composite: true, which is not required.

== Details

This worked for me:

= Directory Structure
workspace
-- tsconfig.json (1)
-- project1
----tsconfig.json (2)
-- project2
----tsconfig.json (3)

= tsconfig.json set up
(1) must have these keys
files=[], references=[path to ./project1 and ./project2]

(2, 3) must have the other keys, including
composite, declaration, target, module, language features

= Debugging
You can tell which config options go where by using
tsc --showConfig
which then has keys
globalConfig corresponding to (1)
and configs corresponding to (2)

@haines
Copy link
Contributor Author

haines commented May 21, 2019

@nullxone the linked repo is set up to be referenced by another project, so composite is required. It's not using the workspace/monorepo pattern you're referring to, so the tsconfig is more like that of the project1/2.

I think you would probably find that you can reproduce this issue in your setup if you add a tsBuildInfoFile option to project1/2 and attempt to run ts-jest from within those projects.

@nullxone
Copy link

Yes, I was able to reproduce the issue as you described.

Here is a workaround.

project
-- tsconfig.json { projects: { path: "./actualtsconfig.json" } }
-- actualtsconfig.json = the current tsconfig json used

You can also include the actualtsconfig.json file from other projects that reference this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants