-
Notifications
You must be signed in to change notification settings - Fork 106
TypeScript issues #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! I wasn't able to reproduce, could you please provide your |
@darrachequesne Sure: { |
hey, same error for me:
my {
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2020",
"sourceMap": true,
"outDir": "dist",
"resolveJsonModule": true,
"esModuleInterop": true,
"allowArbitraryExtensions": true
},
"include": [
"src/**/*"
],
} I use pnpm and build with tsc: {
"name": "server",
"version": "1.0.0",
"main": "dist/index.js",
"license": "MIT",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "node dist/index.js",
"start": "pnpm build && pnpm dev"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.19.2",
"socket.io": "^4.7.5"
},
"devDependencies": {
"@types/node": "^20.12.7",
"typescript": "^5.4.5"
}
} |
Can confirm, also running into this problem. Issue seems to be coming from the type declaration, and not the source file. So while TS is emitting to CJS, the declaration is getting picked up as importing from an ESM module. |
Update: I used source: https://www.typescriptlang.org/tsconfig/#skipLibCheck |
@plvo ... You used the brute force method to make TypeScript shut up. |
@philkunz yes it's not the best solution, I use it because it's a small project, but if there are other solutions, I'm interested |
In order to fix the following issue: > error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@socket.io/component-emitter")' call instead. > > 1 import { Emitter } from "@socket.io/component-emitter"; This problem was introduced in [1], when reworking the dual packaging. Related: socketio/socket.io-parser#132 [1]: ba6b56d
@philkunz I was indeed able to reproduce the issue, thanks for providing your This should be fixed by socketio/emitter@e6aa1a3, included in Could you please check? |
@darrachequesne I comment on the the commit above, but the issue seems fixed for now. |
@darrachequesne Thank you! |
[email protected]/node_modules/socket.io-parser/build/cjs/index.d.ts (1,25): The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@socket.io/component-emitter")' call instead.
The text was updated successfully, but these errors were encountered: