-
Notifications
You must be signed in to change notification settings - Fork 465
Open
Labels
🤷♂️ Needs More Infowaiting for more information from author of the issuewaiting for more information from author of the issue
Description
Version
29.3.2
Steps to reproduce
Following the instructions to make ts-transformer-keys
work with ts-jest
leads to an error at runtime:
TypeError: Cannot read properties of undefined (reading 'transformSourceFile')
Expected behavior
It should work as expected
Actual behavior
A runtime error occurs
TypeError: Cannot read properties of undefined (reading 'transformSourceFile')
at ../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119170:85
at transformation (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119264:14)
at transformRoot (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119287:71)
at transformNodes (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119272:70)
at emitJsFileOrBundle (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119817:24)
at emitSourceFileOrBundle (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119775:5)
at forEachEmittedFile (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119539:24)
at emitFiles (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:119757:3)
at ../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:126907:13
at Object.runWithCancellationToken (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:51211:16)
at emitWorker (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:126905:37)
at ../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:126876:13
at runWithCancellationToken (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:126986:14)
at Object.emit (../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:126875:20)
at transpileWorker (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_bnf6743572yuqcukekff4boeqm/node_modules/ts-jest/dist/transpilers/typescript/transpile-module.js:181:26)
at TsCompiler._transpileOutput (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_bnf6743572yuqcukekff4boeqm/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js:247:57)
at TsCompiler.getCompiledOutput (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_bnf6743572yuqcukekff4boeqm/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js:223:31)
at TsJestCompiler.getCompiledOutput (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_bnf6743572yuqcukekff4boeqm/node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js:14:39)
at TsJestTransformer.processWithTs (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_bnf6743572yuqcukekff4boeqm/node_modules/ts-jest/dist/legacy/ts-jest-transformer.js:259:41)
at TsJestTransformer.process (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_bnf6743572yuqcukekff4boeqm/node_modules/ts-jest/dist/legacy/ts-jest-transformer.js:183:24)
at ScriptTransformer.transformSource (../../node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:545:31)
at ScriptTransformer._transformAndBuildScript (../../node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
at ScriptTransformer.transform (../../node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:726:19)
Debug log
Additional context
jest.config.js
/** @type {import('jest').Config} */
const config = {
preset: "ts-jest",
transform: {
".(ts|tsx)": [
"ts-jest",
{
astTransformers: { before: ["ts-jest-keys-transformer.js"] }
}
]
}
}
ts-jest-keys-transformer.js
const keysTransformer = require("ts-transformer-keys/transformer").default;
const name = "my-key-transformer";
const version = 1;
const factory = (cs) => (ctx) => {
console.log("PROGRAM", cs.program);
keysTransformer(cs.program)(ctx);
};
module.exports = { name, version, factory };
jest v29.7.0
ts-jest v.29.3.2
typescript v5.8.3 (tried also with v5.7.x with same results)
Environment
System:
OS: Linux 6.6 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 20.16.0 - /usr/bin/node
npm: 10.8.1 - /usr/bin/npm
pnpm: 9.12.2 - /usr/bin/pnpm
npmPackages:
jest: ^29.3.1 => 29.7.0
Metadata
Metadata
Assignees
Labels
🤷♂️ Needs More Infowaiting for more information from author of the issuewaiting for more information from author of the issue