iii icon indicating copy to clipboard operation
iii copied to clipboard

Node Module Resolution is being deprecated with TypeScript 7.0

Open amitrayblr opened this issue 9 months ago • 3 comments

Environment

Node 22.20.0

Steps to Reproduce

Copy tsconfig.json from https://www.motia.dev/docs/development-guide/project-structure

{ "compilerOptions": { "target": "ES2020", "module": "ESNext", "moduleResolution": "Node", "esModuleInterop": true, "strict": true, "skipLibCheck": true }, "include": ["**/*.ts", "**/*.tsx"], "exclude": ["node_modules", "dist"] }

Expected Behavior

"moduleResolution": "Node" is being deprecated as of TypeScript 7.0.

According to the official typescript issue, projects that depend on node10 should shift over to "moduleResolution": "bundler"

https://github.com/microsoft/TypeScript/issues/62200

Actual Behavior

npm run dev with "moduleResolution": "Node" runs the app fine. I haven't gotten to the point of adding steps, and building. I assume that the app will build fine.

Switching over to "moduleResolution": "bundler" however causes errors.

Relevant Logs/Console Output

TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.

    at createTSError (/src-motia/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/src-motia/node_modules/ts-node/src/index.ts:863:19)
    at /src-motia/node_modules/ts-node/src/index.ts:1379:34
    at Object.compile (/src-motia/node_modules/ts-node/src/index.ts:1458:13)
    at Module.m._compile (/src-motia/node_modules/ts-node/src/index.ts:1617:30)
    at node:internal/modules/cjs/loader:1839:10
    at require.extensions.<computed> (/src-motia/node_modules/ts-node/src/index.ts:1621:12)
    at Object.require.extensions.<computed> [as .ts] (/src-motia/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1441:32)
    at Function._load (node:internal/modules/cjs/loader:1263:12) {
  diagnosticCodes: [ 5095 ]
}

Screenshots

Image

Motia Version

0.8.4-beta.141

Additional Context

No response

amitrayblr avatar Nov 05 '25 06:11 amitrayblr

Hi @amitrayblr, I'm facing the same issue as well. Would it make sense to temporarily resolve it by adding the ignoreDeprecations flag for now? Then once TypeScript 7 becomes stable and widely supported, we can revisit and properly address this.

Tiru-99 avatar Nov 10 '25 15:11 Tiru-99

Hey @Tiru-99, so this issue was a bit weird for me. Because Motia would build and run without any issues. Did some digging and realised that this was an IDE only error. On the bottom right of VSCode, you will see

Image

If you click on { } next to TypeScript, it will give you a choice to choose the TypeScript version. Mine was showing that it selected VSCode's own 6.xxx version, while my app (workspace) was using 5.9.3 (what's available on npm). Switching to my workspace version seemed to have fixed the error. Without having to use ignoreDeprecations.

amitrayblr avatar Nov 10 '25 17:11 amitrayblr

Hey @Tiru-99, I will address this quickly.

Thanks for pointing it out.

rohitg00 avatar Nov 24 '25 16:11 rohitg00