Skip to content
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

TypeScript error TS1005 when building with version 4.1.1 #3916

Closed
LieutenantCrunch opened this issue May 12, 2021 · 8 comments
Closed

TypeScript error TS1005 when building with version 4.1.1 #3916

LieutenantCrunch opened this issue May 12, 2021 · 8 comments
Labels
bug Something isn't working
Milestone

Comments

@LieutenantCrunch
Copy link

Describe the bug
I updated to version 4.1.1 from version 4.0.2 today and when I try to build, I get two errors:

node_modules/socket.io/dist/namespace.d.ts:131:39 - error TS1005: ',' expected.
131     _onServerSideEmit(args: [eventName: string, ...args: any[]]): void;
                                          ~
node_modules/socket.io/dist/namespace.d.ts:131:56 - error TS1005: ',' expected.
131     _onServerSideEmit(args: [eventName: string, ...args: any[]]): void;
                                                           ~

I'm using the following non-default options in my tsconfig:

{
    "target": "esnext",
    "module": "commonjs",
    "sourceMap": true,
    "strict": true,
    "strictPropertyInitialization": false,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
}

I suspect this is due to the following change from yesterday:
b84ed1e#diff-f11671c8d5a031c5560b560c3fc390bf7509925c4914ec4d60011b3d10420c28

To Reproduce

Socket.IO server version: 4.1.1

Server

import * as http from 'http';
import express from 'express';
import * as SocketIO from 'socket.io';

const app: express.Application = express();
const server: http.Server = http.createServer(app);
const io = new SocketIO.Server();

io.attach(server, { cookie: false });

// Additional Express setup omitted

io.on('connection', (socket: SocketIO.Socket) => {
    console.log(`connect ${socket.id}`);

    socket.on('disconnect', () => {
        console.log(`disconnect ${socket.id}`);
    });
});

server.listen(3000, () => {
    console.log(`Listening on port 3000`);
});

Platform:

  • OS: Windows 7 x64
  • Node.JS 14.16.0
  • Express 4.17.1
  • I do not have @types/socket.io installed
@LieutenantCrunch LieutenantCrunch added the bug Something isn't working label May 12, 2021
@MaximeKjaer
Copy link
Contributor

What version of TypeScript are you using?

I suspect that this issue could be caused by the usage of labeled tuple types in the commit you referenced. This is a new feature in TypeScript 4.0, which I think might be causing trouble if you are using older versions.

@LieutenantCrunch
Copy link
Author

That was the issue! I was running typescript 3.9.6, upgrading to 4+ solved it. Thank you.

@ReneCode
Copy link

same problem here - very nice to read a perfect answer / fix.
Thank you very much @MaximeKjaer , @LieutenantCrunch

@darrachequesne darrachequesne added this to the 4.1.2 milestone May 17, 2021
@darrachequesne
Copy link
Member

This should be fixed by 0cb6ac9, included in socket.io@4.1.2.

@yhawash
Copy link

yhawash commented Jul 18, 2022

The same issue here, i will post my case it maybe face anyone ..

I have express application, it's dockerized

Once the build is start running I got the same issue, I did updated the typescript to version ^4.7.1 still facing the issue, but i realized that docker is still using the local typescript from my PC v3.9.0 !! how ?

The docker up will do the following in sequence:

1- npm install ( will install typescript 4.7)
2- copy . . // will copy the node_modules from local pc to docker container ( since node_modules is not in .dockerignore

So the issue is that I had to add node_modules to .dockerignore file .. and fixed

@hugoebarboza
Copy link

Hello @yhawash how did you solve this issue ?

I have the same issue here.

@OktarianTB
Copy link

Updating the version of the typescript dependency to the latest version fixed the issue for me.

@SalahAdDin
Copy link

Updating the version of the typescript dependency to the latest version fixed the issue for me.

Is there any version compatible with old typescript versions?

dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants