socket.io and typescript
Answered
Sun bear posted this in #help-forum
Sun bearOP
i just want to start project with typescript but it not working
Answered by ncls.
Mostly default:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
24 Replies
What's the error?
Sun bearOP
@ncls.
That's different code now
Sun bearOP
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
What version of socket.io are you using?
Sun bearOP
"version": "4.7.2",
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
serverSun bearOP
can you give me tsconfig
file
@ncls.
i am using pnpm, can this be problem?
Mostly default:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Answer
Sun bearOP
thanks
No idea. Try with NPM but I don't really think that should make a difference
Sun bearOP
it works
Was it the Config?
Sun bearOP
yes
Alright then