You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
astro/check thinks typescript is not installed when using TypeScript 7 #17268
Astro v7.0.5
Node v24.18.0
System Windows (x64)
Package Manager bun
Output static
Adapter none
Integrations fix-mdx-astro7
@astrojs/mdx
astro-icon
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Need to be compatible with TS 7. Currently it think ts is not installed and prompts to install it. Run npm run check or astro check to see the problem.
TypeScript 7 does not currently support languages like Astro, Vue, Svelte. We cannot fix it until they do. Just letting people know why this hasn't been fixed yet.
Unit Test: Yes — packages/astro/test/units/cli/install-package.test.ts
Priority:P4: important. This completely breaks astro check for anyone using TypeScript 7, with no workaround other than downgrading TypeScript.
The getPackage() function in packages/astro/src/cli/install-package.ts uses require.resolve(packageName) to detect whether a package is installed. TypeScript 7 removed its default CJS export entry point (no main field and no . in its exports map), so require.resolve('typescript') throws ERR_PACKAGE_PATH_NOT_EXPORTED instead of resolving. The catch block treats all errors as "package not installed," which is incorrect for this case.
I found a potential fix for this issue. When require.resolve() throws ERR_PACKAGE_PATH_NOT_EXPORTED, the fix falls back to resolving ${packageName}/package.json to confirm the package is actually installed, and returns a truthy value instead of falling through to the install prompt.
Try this fix
You can test this fix right now without waiting for a release:
npm i https://pkg.pr.new/astro@fdec70e
If this fixes your issue, please leave a comment letting us know (e.g. "confirmed, this fixes it"). We'll then open a pull request to get this merged.
Full Triage Report
Issue #17268: astro/check thinks typescript is not installed when using TypeScript 7
Original Issue
Title: astro/check thinks typescript is not installed when using TypeScript 7 Author: robertbaker URL:#17268
Description: When using TypeScript 7 (v7.0.1-rc), running astro check thinks TypeScript is not installed and prompts to install it.
Environment from issue:
Astro v7.0.5
Node v24.18.0
Windows (x64)
Package Manager: bun
Reproduction Result — ✅ Successfully Reproduced
Steps to Reproduce:
Create a project with astro and typescript@7.0.1-rc as dependencies
Run astro check
Actual Result:
$ astro check
To continue, Astro requires the following dependency to be installed: typescript.
[ERROR] [check] The `@astrojs/check` and `typescript` packages are required for this command to work.
Expected Result:astro check should recognize TypeScript 7 as installed and run diagnostics normally.
Root Cause
File:packages/astro/src/cli/install-package.ts, getPackage() function (lines 25-31)
TypeScript 7 removed its default CJS export. Its exports map only contains sub-path exports like ./unstable/sync and ./package.json — no . entry. This causes require.resolve('typescript') to throw ERR_PACKAGE_PATH_NOT_EXPORTED instead of MODULE_NOT_FOUND. The catch block in getPackage() treats ALL errors as "package not installed," conflating "can I import this?" with "is this installed?".
The typescript value returned by getPackage() in check/index.ts is never used as a module — it's only checked for truthiness (if (!typescript)). The function is being used purely as an "is this installed?" check.
Verdict: Bug (high confidence)
No code comments, prior issues, or design rationale suggest this was intentional. The catch-all catch {} was introduced by a lint cleanup commit, not a deliberate design choice. The scenario of a package being installed but having no default export was simply never considered.
When require.resolve() throws ERR_PACKAGE_PATH_NOT_EXPORTED, the fix falls back to resolving ${packageName}/package.json. If that succeeds, the package is confirmed installed and a truthy {} is returned.
-\t} catch {+\t} catch (e) {+\t\tif ((e as NodeJS.ErrnoException)?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {+\t\t\ttry {+\t\t\t\trequire.resolve(`${packageName}/package.json`, {+\t\t\t\t\tpaths: [options.cwd ?? process.cwd()],+\t\t\t\t});+\t\t\t\treturn {} as T;+\t\t\t} catch {+\t\t\t\t// Fall through to install prompt+\t\t\t}+\t\t}
Verification: Before fix → error. After fix → Result (4 files): 0 errors, 0 warnings, 0 hints ✅ Unit test added in packages/astro/test/units/cli/install-package.test.ts. All 36 CLI tests pass. Changeset:.changeset/warm-results-drive.md — astro: patch
This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
Unit Test: Yes — packages/astro/test/units/cli/install-package.test.ts
Priority:P4: important. This completely breaks astro check for anyone using TypeScript 7, with no workaround other than downgrading TypeScript.
TypeScript 7 removed its default CJS entry point (no . in its exports map), so require.resolve('typescript') throws ERR_PACKAGE_PATH_NOT_EXPORTED instead of resolving. This affects two locations: getPackage() in packages/astro/src/cli/install-package.ts (which treats all errors as "not installed") and require.resolve('typescript') in packages/language-tools/astro-check/src/index.ts (which crashes when constructing AstroCheck). The previous fix only addressed the first location — the user confirmed the second location also needs patching.
I found a potential fix for this issue. The fix handles ERR_PACKAGE_PATH_NOT_EXPORTED in both astro core and @astrojs/check by falling back to resolving typescript/package.json, and adds a loadTypeScript() fallback in the language server. The @astrojs/check peerDependencies are also updated to include ^7.0.0.
Try this fix
You can test this fix right now without waiting for a release:
npm i https://pkg.pr.new/astro@2add254
Note: This preview only includes the astro core package. The @astrojs/check changes (resolving TypeScript path and peerDependencies update) are included in the branch but not in this preview build. If you're using pnpm, the astro fix alone may be sufficient since @astrojs/check can resolve TypeScript via module resolution.
If this fixes your issue, please leave a comment letting us know (e.g. "confirmed, this fixes it"). We'll then open a pull request to get this merged.
Full Triage Report
Issue #17268: astro/check thinks typescript is not installed when using TypeScript 7
Original Issue
Title: astro/check thinks typescript is not installed when using TypeScript 7 Author: robertbaker URL:#17268
Description: When using TypeScript 7 (v7.0.1-rc), running astro check thinks TypeScript is not installed and prompts to install it.
Environment from issue:
Astro v7.0.5
Node v24.18.0
Windows (x64)
Package Manager: bun
Reproduction Result — ✅ Successfully Reproduced
Steps to Reproduce:
Create a project with astro and typescript@7.0.1-rc as dependencies
Run astro check
Actual Result:
$ astro check
To continue, Astro requires the following dependency to be installed: typescript.
[ERROR] [check] The `@astrojs/check` and `typescript` packages are required for this command to work.
Expected Result:astro check should recognize TypeScript 7 as installed and run diagnostics normally.
Root Cause
TypeScript 7 removed its default CJS export entry point. Its package.json has \"type\": \"module\" and an exports map with only subpath exports (./unstable/sync, ./package.json, etc.) — no . entry. This causes require.resolve('typescript') to throw ERR_PACKAGE_PATH_NOT_EXPORTED.
Two locations in the codebase are affected:
packages/astro/src/cli/install-package.ts (line 28): getPackage() uses require.resolve() to detect installation. The catch-all block treats ERR_PACKAGE_PATH_NOT_EXPORTED as "not installed" — conflating "can I import this?" with "is this installed?"
packages/language-tools/astro-check/src/index.ts (line 28): require.resolve('typescript') is called to get the TypeScript path for the AstroCheck constructor. This also throws with TS7.
Verdict: Bug (high confidence)
The catch-all catch {} in install-package.ts was introduced by a lint cleanup commit (4c1b769bcf0, chore: bump typescript-eslint to v8), not a deliberate design choice. The require.resolve('typescript') in @astrojs/check was added during the Volar 2 upgrade (15a5532) with no consideration for packages lacking a . export. No prior issues or PRs discuss intentionally excluding TypeScript 7.
Fix
Files changed:
packages/astro/src/cli/install-package.ts — When require.resolve() throws ERR_PACKAGE_PATH_NOT_EXPORTED, fall back to resolving ${packageName}/package.json. If that succeeds, the package is installed — return {} as T.
packages/language-tools/astro-check/src/index.ts — Wrap require.resolve('typescript') in try/catch. On ERR_PACKAGE_PATH_NOT_EXPORTED, resolve typescript/package.json and derive the package directory path.
packages/language-tools/language-server/src/check.ts — Extract TypeScript loading into loadTypeScript() with fallback resolution and a clear error message.
packages/language-tools/astro-check/package.json — Updated peerDependencies to \"^5.0.0 || ^6.0.0 || ^7.0.0\".
Verification: Before fix → error. After fix → Result (4 files): 0 errors, 0 warnings, 0 hints ✅ Regression check: TS6 still works ✅ Unit test added in packages/astro/test/units/cli/install-package.test.ts. All 36 CLI tests pass and all 6 @astrojs/check tests pass. Changeset:.changeset/upset-owls-dance.md — astro: patch, @astrojs/check: patch
Note on full TS7 compatibility: In pnpm setups, @volar/kit resolves TypeScript from its own module context (typically TS6), so the check toolchain works. In flat node_modules (npm) where only TS7 is available, the language server and volar stack may need further updates since TS7 has a completely restructured API.
This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
Once all is said and done, you'll be able to install the Astro Content Mapper:tm: into your project, and just run tsc to check Astro files with TS7 and benefit from TypeScript 7 in the editor. astro check will either be deprecated, or be updated to call tsc or something like that.
Reacted by Stavros Kois, webmaster872, Emanuele Stoppa, Teddy Ortega, Robert Baker, Andrew Hudson, Obi Fortune, mikaello and furtochka
Reacted by Martin Burger, Behrooz Nobakht, Emanuele Stoppa, Andrew Hudson, Obi Fortune, David Osipov and furtochka
In the editor, #17852 is still needed to land before there's full support, but, it's a bit clumsy to support right now anyway since 7.1 is still far from release. Nonetheless, I hope to land it soon!
Reacted by Kyle Wascher, Robert Baker, Vladimir Laskin, kanad, HPCesia and Yohanes Bandung Bondowoso
Activity
astrobot-houston commentedon Jul 2, 2026
packages/astro/test/units/cli/install-package.test.tsastro checkfor anyone using TypeScript 7, with no workaround other than downgrading TypeScript.The
getPackage()function inpackages/astro/src/cli/install-package.tsusesrequire.resolve(packageName)to detect whether a package is installed. TypeScript 7 removed its default CJS export entry point (nomainfield and no.in itsexportsmap), sorequire.resolve('typescript')throwsERR_PACKAGE_PATH_NOT_EXPORTEDinstead of resolving. The catch block treats all errors as "package not installed," which is incorrect for this case.I found a potential fix for this issue. When
require.resolve()throwsERR_PACKAGE_PATH_NOT_EXPORTED, the fix falls back to resolving${packageName}/package.jsonto confirm the package is actually installed, and returns a truthy value instead of falling through to the install prompt.Try this fix
You can test this fix right now without waiting for a release:
If this fixes your issue, please leave a comment letting us know (e.g. "confirmed, this fixes it"). We'll then open a pull request to get this merged.
Full Triage Report
Issue #17268: astro/check thinks typescript is not installed when using TypeScript 7
Original Issue
Title: astro/check thinks typescript is not installed when using TypeScript 7
Author: robertbaker
URL: #17268
Description: When using TypeScript 7 (v7.0.1-rc), running
astro checkthinks TypeScript is not installed and prompts to install it.Environment from issue:
Reproduction Result — ✅ Successfully Reproduced
Steps to Reproduce:
astroandtypescript@7.0.1-rcas dependenciesastro checkActual Result:
Expected Result:
astro checkshould recognize TypeScript 7 as installed and run diagnostics normally.Root Cause
File:
packages/astro/src/cli/install-package.ts,getPackage()function (lines 25-31)TypeScript 7 removed its default CJS export. Its
exportsmap only contains sub-path exports like./unstable/syncand./package.json— no.entry. This causesrequire.resolve('typescript')to throwERR_PACKAGE_PATH_NOT_EXPORTEDinstead ofMODULE_NOT_FOUND. The catch block ingetPackage()treats ALL errors as "package not installed," conflating "can I import this?" with "is this installed?".The
typescriptvalue returned bygetPackage()incheck/index.tsis never used as a module — it's only checked for truthiness (if (!typescript)). The function is being used purely as an "is this installed?" check.Verdict: Bug (high confidence)
No code comments, prior issues, or design rationale suggest this was intentional. The catch-all
catch {}was introduced by a lint cleanup commit, not a deliberate design choice. The scenario of a package being installed but having no default export was simply never considered.Fix
File changed:
packages/astro/src/cli/install-package.tsWhen
require.resolve()throwsERR_PACKAGE_PATH_NOT_EXPORTED, the fix falls back to resolving${packageName}/package.json. If that succeeds, the package is confirmed installed and a truthy{}is returned.Verification: Before fix → error. After fix →
Result (4 files): 0 errors, 0 warnings, 0 hints✅Unit test added in
packages/astro/test/units/cli/install-package.test.ts. All 36 CLI tests pass.Changeset:
.changeset/warm-results-drive.md—astro: patchThis report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
robertbaker commentedon Jul 2, 2026
@astrobot-houston no, still getting the prompt that typescript is not installed. need to patch @astrojs/check too
matthewp commentedon Jul 2, 2026
@robertoms99 we fixed a similar issue yesterday (not released), can you test this?
fix: detect packages with no default CJS export in getPackage (TypeSc…
astrobot-houston commentedon Jul 2, 2026
packages/astro/test/units/cli/install-package.test.tsastro checkfor anyone using TypeScript 7, with no workaround other than downgrading TypeScript.TypeScript 7 removed its default CJS entry point (no
.in itsexportsmap), sorequire.resolve('typescript')throwsERR_PACKAGE_PATH_NOT_EXPORTEDinstead of resolving. This affects two locations:getPackage()inpackages/astro/src/cli/install-package.ts(which treats all errors as "not installed") andrequire.resolve('typescript')inpackages/language-tools/astro-check/src/index.ts(which crashes when constructingAstroCheck). The previous fix only addressed the first location — the user confirmed the second location also needs patching.I found a potential fix for this issue. The fix handles
ERR_PACKAGE_PATH_NOT_EXPORTEDin bothastrocore and@astrojs/checkby falling back to resolvingtypescript/package.json, and adds aloadTypeScript()fallback in the language server. The@astrojs/checkpeerDependencies are also updated to include^7.0.0.Try this fix
You can test this fix right now without waiting for a release:
Note: This preview only includes the
astrocore package. The@astrojs/checkchanges (resolving TypeScript path and peerDependencies update) are included in the branch but not in this preview build. If you're using pnpm, theastrofix alone may be sufficient since@astrojs/checkcan resolve TypeScript via module resolution.If this fixes your issue, please leave a comment letting us know (e.g. "confirmed, this fixes it"). We'll then open a pull request to get this merged.
Full Triage Report
Issue #17268: astro/check thinks typescript is not installed when using TypeScript 7
Original Issue
Title: astro/check thinks typescript is not installed when using TypeScript 7
Author: robertbaker
URL: #17268
Description: When using TypeScript 7 (v7.0.1-rc), running
astro checkthinks TypeScript is not installed and prompts to install it.Environment from issue:
Reproduction Result — ✅ Successfully Reproduced
Steps to Reproduce:
astroandtypescript@7.0.1-rcas dependenciesastro checkActual Result:
Expected Result:
astro checkshould recognize TypeScript 7 as installed and run diagnostics normally.Root Cause
TypeScript 7 removed its default CJS export entry point. Its
package.jsonhas\"type\": \"module\"and anexportsmap with only subpath exports (./unstable/sync,./package.json, etc.) — no.entry. This causesrequire.resolve('typescript')to throwERR_PACKAGE_PATH_NOT_EXPORTED.Two locations in the codebase are affected:
packages/astro/src/cli/install-package.ts(line 28):getPackage()usesrequire.resolve()to detect installation. The catch-all block treatsERR_PACKAGE_PATH_NOT_EXPORTEDas "not installed" — conflating "can I import this?" with "is this installed?"packages/language-tools/astro-check/src/index.ts(line 28):require.resolve('typescript')is called to get the TypeScript path for theAstroCheckconstructor. This also throws with TS7.Verdict: Bug (high confidence)
The catch-all
catch {}ininstall-package.tswas introduced by a lint cleanup commit (4c1b769bcf0,chore: bump typescript-eslint to v8), not a deliberate design choice. Therequire.resolve('typescript')in@astrojs/checkwas added during the Volar 2 upgrade (15a5532) with no consideration for packages lacking a.export. No prior issues or PRs discuss intentionally excluding TypeScript 7.Fix
Files changed:
packages/astro/src/cli/install-package.ts— Whenrequire.resolve()throwsERR_PACKAGE_PATH_NOT_EXPORTED, fall back to resolving${packageName}/package.json. If that succeeds, the package is installed — return{} as T.packages/language-tools/astro-check/src/index.ts— Wraprequire.resolve('typescript')in try/catch. OnERR_PACKAGE_PATH_NOT_EXPORTED, resolvetypescript/package.jsonand derive the package directory path.packages/language-tools/language-server/src/check.ts— Extract TypeScript loading intoloadTypeScript()with fallback resolution and a clear error message.packages/language-tools/astro-check/package.json— Updated peerDependencies to\"^5.0.0 || ^6.0.0 || ^7.0.0\".Verification: Before fix → error. After fix →
Result (4 files): 0 errors, 0 warnings, 0 hints✅Regression check: TS6 still works ✅
Unit test added in
packages/astro/test/units/cli/install-package.test.ts. All 36 CLI tests pass and all 6@astrojs/checktests pass.Changeset:
.changeset/upset-owls-dance.md—astro: patch,@astrojs/check: patchNote on full TS7 compatibility: In pnpm setups,
@volar/kitresolves TypeScript from its own module context (typically TS6), so the check toolchain works. In flatnode_modules(npm) where only TS7 is available, the language server and volar stack may need further updates since TS7 has a completely restructured API.This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
41 remaining items
chore(deps): bump the javascript-dependencies group across 1 director…
Princesseuh commentedon Sep 4, 2026
Just to give a progress report since I know many people are following this issue, here's where we stand:
Once all is said and done, you'll be able to install the Astro Content Mapper:tm: into your project, and just run
tscto check Astro files with TS7 and benefit from TypeScript 7 in the editor.astro checkwill either be deprecated, or be updated to calltscor something like that.chore(deps): upgrade typescript 5.9.3 -> 6.0.3
Princesseuh commentedon Sep 17, 2026
An update on this:
typescript@next(7.1+)astro checkto give you instructions on this when using TypeScript 7.In the editor, #17852 is still needed to land before there's full support, but, it's a bit clumsy to support right now anyway since 7.1 is still far from release. Nonetheless, I hope to land it soon!
fix: restore lint and type-checking (downgrade to TypeScript 6)
Bump all dependencies (#36)
chore: hold TypeScript below 7 until @astrojs/check supports it (#180)
Adopt TypeScript 7 via tsc content mapper instead of astro check
Bump the major group with 19 updates (#161)
Dependabot: hold back TypeScript 7 only
Dependabot: hold back TypeScript 7 and major @types/node updates (#287)
chore(dependabot): ignore TypeScript major updates (#97)
Dependabot: ignore TypeScript major updates until Astro supports TS 7 (…
build(deps-dev): bump typescript to 6.0.3 in /apps/web; hold 7.x