#socket.io and typescript

26 messages · Page 1 of 1 (latest)

deep agate
#

i just want to start project with typescript but it not working

fierce tigerBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

rotund copper
deep agate
#

@rotund copper

rotund copper
#

That's different code now

deep agate
#

when i create new Socket

#

yes but error is same

#

when i create Socket

#

and add option cors

#

it says that the constructor doesnt exist

rotund copper
deep agate
#

"version": "4.7.2",

rotund copper
#

Hmm... Using the same version and following code works fine for me:

import express from 'express'
import http from 'http'
import { Server } from 'socket.io'

const app = express()
const server = http.createServer(app)

const io = new Server(server, {
  cors: {
    origin: '*'
  }
})
#

Maybe try it with an http server

deep agate
#

can you give me tsconfig

#

file

#

@rotund copper

#

i am using pnpm, can this be problem?

rotund copper
#

Mostly default:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "outDir": "./dist",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}
deep agate
#

thanks

#

it works

rotund copper
#

Was it the Config?

deep agate
#

yes

rotund copper
#

Alright then