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
TypeScript type breakage under pnpm / preserveSymlinks=true due to extending Emitter from another package #5411
Is your feature request related to a problem? Please describe.
When using socket.io-client in a symlinked setup (such as pnpm + preserveSymlinks=true or local linking via npm link), TypeScript loses several instance methods (on, emit, etc.) on the Socket class.
This happens because Socket extends the Emitter class from the @socket.io/component-emitter package:
import { Emitter } from "@socket.io/component-emitter";
export class Socket extends Emitter { ... }
Under preserveSymlinks=true, there can be multiple physical copies of @socket.io/component-emitter, resulting in distinct module identities for TypeScript.
As a result, Socket no longer appears to implement the correct emitter API.
This affects:
pnpm users (the default node_modules structure is symlink-based)
You should not use TypeScript with preserveSymlinks set to true. TypeScript will not be able to resolve the type dependencies correctly in the linked node_modules. If you do need to preserve symlinks for some reason, then you should set pnpm's nodeLinker setting to hoisted.
You should not use TypeScript with preserveSymlinks set to true. TypeScript will not be able to resolve the type dependencies correctly in the linked node_modules. If you do need to preserve symlinks for some reason, then you should set pnpm's nodeLinker setting to hoisted.
Hey there, while I agree, socket.io-client was my only package that broke. I didn't realize, but I had preserveSymlinks on for over a year. This is how I found the behavior in socket.io-client.
Activity
darrachequesne commentedon Nov 4, 2025
Hi! I think this is a limitation from
pnpm:Reference: https://pnpm.io/typescript
anthonyalayo commentedon Nov 4, 2025
Hey there, while I agree, socket.io-client was my only package that broke. I didn't realize, but I had
preserveSymlinkson for over a year. This is how I found the behavior in socket.io-client.