Skip to content

[Bug]: throw error when use typescript5.6 #4637

@beliefgp

Description

@beliefgp

Version

29.2.5

Steps to reproduce

npx jest

/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  testMatch: ['**/*.test.[jt]s?(x)'],
  testPathIgnorePatterns: ['\\\\node_modules\\\\'],
  transform: {
    '^.+.tsx?$': [
      'ts-jest',
      {
        tsconfig: './tsconfig.base.json',
      },
    ],
  },
  collectCoverage: false,
  testTimeout: 60000,
};

tsconfig

{
  "compilerOptions": {
    "target": "es2020",
    "module": "esnext",
    "moduleResolution": "node",
    "declaration": true,
    "esModuleInterop": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strict": true,
    "skipLibCheck": true,
    "preserveSymlinks": false,
    "allowSyntheticDefaultImports": true,
    "jsx": "preserve",
    "verbatimModuleSyntax": true
    // "preserveValueImports": true
  },
  "exclude": ["**/node_modules", "**/examples", "**/dist", "**/fixtures", "**/*.e2e.ts", "**/templates"]
}

Expected behavior

can run

Actual behavior

Cannot read properties of undefined (reading 'sourceFile')

Debug log

Test suite failed to run

TypeError: Cannot read properties of undefined (reading 'sourceFile')

  at isDocumentRegistryEntry (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:140899:18)
  at getDocumentRegistryEntry (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:140975:19)
  at Object.releaseDocumentWithKey (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:141070:19)
  at releaseOldSourceFile (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:149911:24)
  at Object.onReleaseOldSourceFile (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:149915:7)
  at createProgram (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:124974:14)
  at synchronizeHostDataWorker (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:149871:15)
  at synchronizeHostData (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:149767:7)
  at Object.getEmitOutput (node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/typescript.js:150327:5)

Additional context

No response

Environment

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M3
  Binaries:
    Node: 16.20.2
    npm: 8.19.4
    pnpm: 8.15.9
  npmPackages:
    jest: ^29.7.0 => 29.7.0

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions