Site icon JD Bots

Fixed: “TypeError: Cannot read properties of undefined (reading ‘Intrinsic’)” with TypeScript 7

If npm run build fails with “TypeError: Cannot read properties of undefined (reading ‘Intrinsic’)” right after you install TypeScript 7, a build tool is looking for a part of TypeScript that version 7 doesn’t ship. This post shows the error, the one check that explains it, and the fix that TypeScript’s own announcement recommends.

What I Was Doing

I was moving a new TanStack Start app to TypeScript 7, the newest release, while writing TanStack Start Tutorial — Part 2. The app was made with the TanStack CLI and its Netlify option, and the CLI’s template installs TypeScript 6. I upgraded it with npm:

npm install --save-dev typescript@7 @types/node@26 @biomejs/biome@2

Then I built the app:

npm run build

What I Expected

The build to finish as it does with TypeScript 6, with a “✓ built” line for the browser code and another for the server code.

What I Got

Vite stopped while it was loading its own settings file:

npm notice run build
npm notice run vite build
failed to load config from /Users/user/tanstack-lab/bookshop/vite.config.ts
error during build:
TypeError: Cannot read properties of undefined (reading 'Intrinsic')
    at Object.<anonymous> (/Users/user/tanstack-lab/bookshop/node_modules/ts-api-utils/lib/index.cjs:787:57)
    at Module._compile (node:internal/modules/cjs/loader:1968:14)
    at Object..js (node:internal/modules/cjs/loader:2108:10)
    at Module.load (node:internal/modules/cjs/loader:1690:32)
    at Module._load (node:internal/modules/cjs/loader:1480:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
    at Module.require (node:internal/modules/cjs/loader:1713:12)
    at require (node:internal/modules/helpers:318:16)
    at Object.<anonymous> (/Users/user/tanstack-lab/bookshop/node_modules/precinct/node_modules/@typescript-eslint/typescript-estree/dist/convert-comments.js:37:30)
    at Module._compile (node:internal/modules/cjs/loader:1968:14)
The build fails as soon as Vite loads the config.

What I Checked

The stack trace names two packages: ts-api-utils, where the error is thrown, and typescript-estree, which loaded it. Neither is in the app’s own package.json. The one check that mattered was asking npm which TypeScript each package gets:

npm ls typescript --all
bookshop@ /Users/user/tanstack-lab/bookshop
├─┬ @netlify/vite-plugin-tanstack-start@1.3.19
│ └─┬ @netlify/vite-plugin@3.0.1
│   └─┬ @netlify/dev@5.2.0
│     └─┬ @netlify/functions-dev@2.0.18
│       └─┬ @netlify/zip-it-and-ship-it@16.6.0
│         └─┬ precinct@12.3.2
│           ├─┬ detective-typescript@14.1.2
│           │ ├─┬ @typescript-eslint/typescript-estree@8.73.0
│           │ │ ├─┬ @typescript-eslint/project-service@8.73.0
│           │ │ │ └── typescript@5.9.3 deduped
│           │ │ ├─┬ @typescript-eslint/tsconfig-utils@8.73.0
│           │ │ │ └── typescript@5.9.3 deduped
│           │ │ ├─┬ ts-api-utils@2.5.0
│           │ │ │ └── typescript@7.0.2 deduped
│           │ │ └── typescript@5.9.3 deduped
│           │ └── typescript@5.9.3 deduped
│           ├─┬ detective-vue2@2.3.0
│           │ └── typescript@5.9.3 deduped
│           └── typescript@5.9.3
└── typescript@7.0.2

The chain starts at the Netlify plugin. Everything inside precinct gets its own TypeScript 5.9.3, except ts-api-utils, which uses the app’s TypeScript: now 7.0.2.

TypeScript 7’s announcement explains why that breaks: “While TypeScript 7.0 is here, it does not ship with an API.”

Why It Happens

TypeScript 7 is a native port of the compiler, written in Go. It checks your code as before, but its npm package no longer includes the JavaScript programming interface that tools load with require("typescript"). As soon as ts-api-utils loads, it reads TypeFlags.Intrinsic from that interface. With TypeScript 7 there’s no TypeFlags, so the read fails, and Vite can’t load its config.

The Fix

Install TypeScript 7 side by side with TypeScript 6’s compatibility package, as the announcement recommends. Tools that ask for typescript get TypeScript 6’s interface, and TypeScript 7 runs your type checks under the name @typescript/native:

npm install --save-dev @typescript/native@npm:typescript@7 typescript@npm:@typescript/typescript6@6
added 2 packages, changed 1 package, and audited 658 packages in 2s

211 packages are looking for funding
  run `npm fund` for details

31 vulnerabilities (7 moderate, 24 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
npm warn install-scripts 2 packages had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts   esbuild@0.28.1 (postinstall: node install.js)
npm warn install-scripts   fsevents@2.3.3 (install: (install scripts present))
npm warn install-scripts
npm warn install-scripts Run `npm install-scripts ls` to review, or `npm install-scripts approve <pkg>` to allow.

The two entries in package.json now look like this:

package.json (excerpt)

"@typescript/native": "npm:typescript@^7.0.2",
"typescript": "npm:@typescript/typescript6@^6.0.2",

npx tsc still runs TypeScript 7:

npx tsc --version
npm notice run npx
npm notice run 'tsc' --version
Version 7.0.2

After the Fix

The build finishes again:

npm run build
After the fix, both builds finish.

The type check with TypeScript 7, npx tsc --noEmit, finishes without errors too.

Common Mistakes

MistakeWhat happensDo this instead
Installing typescript@7 under the name typescriptTools that load TypeScript’s interface fail, and the build stopsInstall TypeScript 7 as @typescript/native
Removing the typescript packageThose tools can’t find TypeScript at allKeep the compatibility package under that name
Running tsc6 to check your codeIt runs TypeScript 6, not 7Run npx tsc

Troubleshooting

ProblemFix
The error comes back after you add packagesCheck that package.json still has both entries from the fix.
npm prints “ERESOLVE overriding peer dependency” warningsThey concern an optional TypeScript 7.1 preview. The build and the type check still pass.

FAQ

Is this only a Netlify problem? In this app, the package that fails comes with the Netlify plugin. Any tool that loads TypeScript’s programming interface needs the same side-by-side setup with TypeScript 7.0, and the announcement names typescript-eslint as one.

Will TypeScript 7.1 change this? The announcement expects TypeScript 7.1 to ship a new, different API. Tools need updates to use it, so keep the side-by-side setup until they do.

Conclusion

TypeScript 7.0 has no programming interface yet, so a tool that loads it as typescript fails. Install TypeScript 7 as @typescript/native and give the name typescript to the TypeScript 6 compatibility package. Your code is checked by TypeScript 7, and the build works.

Additional Resources

Related

TanStack, React and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by TanStack.

Exit mobile version