bunx tsc --project tsconfig.json
fails with the error
<code>node_modules/@types/node/globals.d.ts:6:76 - error TS2792: Cannot find module 'undici-types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
... more of similar errors
</code>
<code>node_modules/@types/node/globals.d.ts:6:76 - error TS2792: Cannot find module 'undici-types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
... more of similar errors
</code>
node_modules/@types/node/globals.d.ts:6:76 - error TS2792: Cannot find module 'undici-types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
... more of similar errors
I checked the source of the problem, and it looks conditional load, seems like globalThis
is not defined.
<code>...
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
...
</code>
<code>...
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
...
</code>
...
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
...
How it could be fixed?
bun -v 1.1.16
<code>{
"scripts": {
"build": "tsc --project tsconfig.json"
},
"devDependencies": {
"typescript": "^5.5.2",
"bun-types": "^1.1.16"
},
"dependencies": {
}
}
</code>
<code>{
"scripts": {
"build": "tsc --project tsconfig.json"
},
"devDependencies": {
"typescript": "^5.5.2",
"bun-types": "^1.1.16"
},
"dependencies": {
}
}
</code>
{
"scripts": {
"build": "tsc --project tsconfig.json"
},
"devDependencies": {
"typescript": "^5.5.2",
"bun-types": "^1.1.16"
},
"dependencies": {
}
}
tsconfig.json
<code>{
"compilerOptions": {
"module": "es2022",
"lib": ["dom", "es2022"],
"target": "es2022",
"rootDir": ".",
"outDir": "build",
},
"include": [
"**/*.ts",
"**/*.tsx"
],
"exclude": [
}
</code>
<code>{
"compilerOptions": {
"module": "es2022",
"lib": ["dom", "es2022"],
"target": "es2022",
"rootDir": ".",
"outDir": "build",
},
"include": [
"**/*.ts",
"**/*.tsx"
],
"exclude": [
}
</code>
{
"compilerOptions": {
"module": "es2022",
"lib": ["dom", "es2022"],
"target": "es2022",
"rootDir": ".",
"outDir": "build",
},
"include": [
"**/*.ts",
"**/*.tsx"
],
"exclude": [
}
typescript file
<code>console.log("hi")
</code>
<code>console.log("hi")
</code>
console.log("hi")