{"record":{"id":"cab537ff26c05536","repo":"jestjs/jest","slug":"jest-loader-is-not-a-valid-typescript-config","errorCode":null,"errorMessage":"Jest: '${loader}' is not a valid TypeScript configuration loader.","messagePattern":"Jest: '(.+?)' is not a valid TypeScript configuration loader\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-config/src/readConfigFileAndSetRootDir.ts","lineNumber":232,"sourceCode":"      );\n\n      let instance: {unregister: () => void} | undefined;\n\n      return {\n        enabled: (bool: boolean) => {\n          if (bool) {\n            instance = tsLoader.register({\n              target: `node${process.version.slice(1)}`,\n              ...extraTSLoaderOptions,\n            });\n          } else {\n            instance?.unregister();\n          }\n        },\n      };\n    }\n\n    throw new Error(\n      `Jest: '${loader}' is not a valid TypeScript configuration loader.`,\n    );\n  } catch (error) {\n    if (\n      isError(error) &&\n      (error as NodeJS.ErrnoException).code === 'ERR_MODULE_NOT_FOUND'\n    ) {\n      throw new Error(\n        `Jest: '${loader}' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${error.message}`,\n        {cause: error},\n      );\n    }\n\n    throw error;\n  }\n}\n","sourceCodeStart":214,"sourceCodeEnd":249,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L214-L249","documentation":"Thrown by registerTsLoader when the loader name from the @jest-config-loader pragma is neither 'ts-node' nor 'esbuild-register'. The TsLoaderModule type is a closed union, so any other value falls through both branches and reaches this terminal throw.","triggerScenarios":"Typing the pragma value incorrectly (e.g. 'tsx', 'swc', '@swc/register', 'ts-node/register'), using a trailing path, or misspelling 'ts-node'/'esbuild-register'.","commonSituations":"Developers wanting to use a newer TS loader (tsx, swc) that Jest does not yet accept; copy-paste typos; assuming the pragma accepts the same names as --require flags.","solutions":["Use exactly 'ts-node' or 'esbuild-register' as the @jest-config-loader value","Install the chosen loader as a devDependency","If you need a different loader, fall back to native Node TS support (Node 22.18+/23.6+) instead of the pragma"],"exampleFix":"/**\n * @jest-config-loader tsx\n */\n// before: invalid -> error\n\n/**\n * @jest-config-loader esbuild-register\n */\n// after: valid loader","handlingStrategy":"validation","validationCode":"import { extract, parse } from 'jest-docblock';\nimport * as fs from 'node:fs';\nconst VALID_LOADERS = ['ts-node', 'esbuild-register'] as const;\nconst pragmas = parse(extract(fs.readFileSync('jest.config.ts', 'utf8')));\nconst loader = pragmas['jest-config-loader'];\nif (typeof loader === 'string' && !VALID_LOADERS.includes(loader as any)) {\n  throw new Error(`Unsupported loader: ${loader}. Use one of ${VALID_LOADERS.join(', ')}`);\n}","typeGuard":"type TsLoaderName = 'ts-node' | 'esbuild-register';\nfunction isTsLoaderName(value: unknown): value is TsLoaderName {\n  return value === 'ts-node' || value === 'esbuild-register';\n}","tryCatchPattern":null,"preventionTips":["Reference the loader name from a shared constant to avoid typos","Prefer native Node TS support (no pragma) when on Node 22.18+/23.6+","Document the two valid loader values in your repo's contributing guide"],"tags":["typescript","config","docblock","loader","argument-validation"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}