{"record":{"id":"682a8535aed204c7","repo":"withastro/astro","slug":"the-typescript-module-loaded-version-does-not-ex","errorCode":null,"errorMessage":"The TypeScript module loaded${version} does not expose the programmatic API that `astro check` relies on. TypeScript's native compiler (7.0 and later) does not ship this API yet. Until it does, run `astro check` with a TypeScript version that still provides it (6.x). See https://github.com/withastro/roadmap/discussions/1321 to track support.","messagePattern":"The TypeScript module loaded(.+?) does not expose the programmatic API that `astro check` relies on\\. TypeScript's native compiler \\(7\\.0 and later\\) does not ship this API yet\\. Until it does, run `astro check` with a TypeScript version that still provides it \\(6\\.x\\)\\. See https://github\\.com/withastro/roadmap/discussions/1321 to track support\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/language-tools/language-server/src/check.ts","lineNumber":209,"sourceCode":"\t\t\t\t\t\tthis.ts,\n\t\t\t\t\t\tlanguageServiceHost,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * The checker is built on Volar and TypeScript's programmatic Language Service API\n\t * (`ts.sys`, `ts.findConfigFile`, `LanguageServiceHost`, etc.). TypeScript's native\n\t * compiler does not ship that API yet — `require('typescript')` only exposes `version`\n\t * and `versionMajorMinor` — so continuing would crash later with an opaque\n\t * `Cannot read properties of undefined` error. Fail early with an actionable message.\n\t */\n\tprivate assertCompatibleTypeScript() {\n\t\tif (typeof this.ts.findConfigFile !== 'function' || this.ts.sys === undefined) {\n\t\t\tconst version = this.ts.version ? ` (found ${this.ts.version})` : '';\n\t\t\tthrow new Error(\n\t\t\t\t`The TypeScript module loaded${version} does not expose the programmatic API that \\`astro check\\` relies on. ` +\n\t\t\t\t\t`TypeScript's native compiler (7.0 and later) does not ship this API yet. ` +\n\t\t\t\t\t`Until it does, run \\`astro check\\` with a TypeScript version that still provides it (6.x). ` +\n\t\t\t\t\t`See https://github.com/withastro/roadmap/discussions/1321 to track support.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getTsconfig() {\n\t\tif (this.tsconfigPath) {\n\t\t\tconst tsconfig = resolve(this.workspacePath, this.tsconfigPath.replace(/^~/, homedir()));\n\t\t\tif (!existsSync(tsconfig)) {\n\t\t\t\tthrow new Error(`Specified tsconfig file \\`${tsconfig}\\` does not exist.`);\n\t\t\t}\n\t\t\treturn tsconfig;\n\t\t}\n\n\t\tconst searchPath = this.workspacePath;","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/language-tools/language-server/src/check.ts#L191-L227","documentation":"Thrown by the Astro language server's `assertCompatibleTypeScript()` when the loaded TypeScript module exposes only `version`/`versionMajorMinor` (the shape of TypeScript 7.x native compiler) but not the programmatic API (`ts.sys`, `ts.findConfigFile`) that `astro check` depends on via Volar. It fails early instead of crashing later with an opaque undefined-access error.","triggerScenarios":"Running `astro check` in a project whose resolved `typescript` is 7.0+ (native compiler, no LanguageService API). Forcing `typescript.tsdk` to a TS 7 lib path. A toolchain (e.g. a newer bundler) hoisting TS 7 over TS 6.x.","commonSituations":"Upgrading TypeScript globally or in the project to 7.x. IDE/editor injecting a TS 7 lib. A fresh install resolving the latest TS major.","solutions":["Downgrade the project's TypeScript to 6.x: `pnpm add -D typescript@~6`.","Ensure the `typescript.tsdk` init option points at a 6.x lib directory.","Track the Astro roadmap discussion linked in the message for when TS 7 support lands."],"exampleFix":"// before: typescript 7 resolved\npnpm add -D typescript@latest\n// after\npnpm add -D typescript@~6","handlingStrategy":"type-guard","validationCode":"import * as ts from 'typescript';\nif (typeof ts.findConfigFile !== 'function' || ts.sys === undefined) {\n  throw new Error('Incompatible TypeScript 7+; pin typescript@~6 for astro check.');\n}","typeGuard":"function hasLanguageServiceAPI(ts: typeof import('typescript')): boolean {\n  return typeof ts.findConfigFile === 'function' && ts.sys !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Pin `typescript` to a 6.x range in devDependencies.","Lock the editor's tsdk to the workspace TS.","Track the Astro roadmap discussion for TS 7 support."],"tags":["language-tools","typescript","version","astro-check","compatibility"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}