-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Types are not installed #4621
Comments
Hi! That's weird, the types should be included in the package. Which OS are you using? Which version of |
Hi I'm on Windows 11, and I'm using verion |
That's really weird. The types are declared there:
And are included in the package:
Not sure what's going wrong here. |
This is probably because of typescript. This is my
I tried to set module to |
I'm running into the same issue, using commonjs fixes the problem, however a few of the packages i need are pure esm only, so changing to commonjs isn't an alternative.
and
|
The types are present though (in |
I am on the latest
Seems like this bug has re-occur: #3796. |
Just submitted PRs to fix this on socket.io and engine.io Tested with the following config:
|
I was able to downgrade to |
Is there an extra step I need to take besides installing
tsconfig.json {
"compilerOptions": {
"target": "es2022",
"lib": [ "es2022", "DOM" ],
"module": "es2022",
"rootDir": "src",
"allowJs": false,
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"moduleResolution": "node16"
}
} |
Yeah on version 4.6.1 still getting the same error is there something wrong with our implementation of running a client websocket?: ❯ npm list socket.io
<app_directory>
`-- socket.io@4.6.1 #0 12.97 app/Services/Ws.ts:25:23 - error TS2345: Argument of type '(nsp: any) => ClusterAdapter' is not assignable to parameter of type 'AdapterConstructor'.
#0 12.97 Type '(nsp: any) => ClusterAdapter' is not assignable to type '(nsp: Namespace<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap, any>) => Adapter'.
#0 12.97 Type 'ClusterAdapter' is missing the following properties from type 'Adapter': _encode, persistSession, restoreSession
#0 12.97
#0 12.97 25 this.srv.adapter(createAdapter())
#0 12.97 ~~~~~~~~~~~~~~~
#0 12.97
#0 12.97
#0 12.97 Cannot complete the build process as there are typescript errors. Use "--ignore-ts-errors" flag to ignore Typescript errors
#0 12.97 [ info ] cleaning up "./build" directory // socket.ts
import {Server} from 'socket.io'
import {createAdapter} from '@socket.io/cluster-adapter'
import {setupWorker} from '@socket.io/sticky'
...
class ClientWS {
public srv: Server
public boot() {
...
this.srv = new Server(AdonisServer.instance!, {
path: <path>,
cors: <cors>
})
this.srv.adapter(createAdapter())
setupWorker(this.srv)
}
}
export default new ClientWS() |
@jcjp this should be fixed in |
I too still have the exact same problem as @Metapyziks on version |
I have This is my tsconfig.json:
Node version v18.15.0 |
The import added in [1] was invalid, because it used an non-exported class. Related: socketio#4621 [1]: socketio@d4a9b2c
I see there have been some fix commits--can these be published if they resolve the issue? |
The type definitions for the CommonJS target of this library seem to be broken (as of There are no type definitions in the
How to fix this?You have two options to fix this: Option 1: Reference
|
@kettanaito thanks for the detailed analysis 👍
So if I'm understanding correctly, the bundler does understand
Out of curiosity, which bundler has this behavior? |
@darrachequesne, yes, you are correct. At least, this is the behavior I'm getting using TypeScript 5.0 in some of my open-source projects. I've gone through an extensive implementation of ESM+TS recently for some of my projects and know firsthand how painful it is to get this right for every consumer. |
Hello, I am also experiencing this now on our CI build.
My devDependencies have:
And tsconfig.json:
|
@kettanaito we went for option 2 in socketio/socket.io-parser@dcc70d9, included in Update: @24thsaint the types are now included in the package, there should be no need for the |
Hi @darrachequesne , It's a peer dependency coming from:
Looks like it's using:
I'm on:
|
The import added in [1] was invalid, because it used an non-exported class. Related: socketio#4621 [1]: socketio@6652a3f
Describe the bug
Types for
socket.io-parser
andengine.io-parser
are not installedTo Reproduce
Socket.IO server version:
4.5.4
When compile with typescript it throws these errors:
Did I do something wrong?
Do I have to install the types manually?
The text was updated successfully, but these errors were encountered: