probil / vue-socket.io-extended

:v::zap: Socket.io bindings for Vue.js and Vuex (inspired by Vue-Socket.io)
MIT License
628 stars 38 forks source link

Vue 3 Object(...) is not a function #528

Open ReazerDev opened 3 years ago

ReazerDev commented 3 years ago

Hi, I'm using alpha5 and when I'm trying to use the Socket Decorator I get a TypeError in the function beneath it: Object(...) is not a function. image When I remove the Decorator, the TypeError is gone.

Also when running npm run serve, I get a warning: image

jnt0r commented 3 years ago

Are you sure you're using alpha5? Newest I can found is alpha4. And there everything is working for me using @Socket Decorator. Maybe you could provide some more context of your code. The first thing I would think of is the import of Socket. Maybe it's not correct.

jnt0r commented 3 years ago

Okay, I need to correct my comment. Got the warning on compile-time too. Remembered that there were some breaking changes in alpha stated here https://github.com/probil/vue-socket.io-extended/issues/489#issuecomment-771497973

probil commented 3 years ago

@ReazerDev In v5 decorator is supposed to be imported from the sub-path:

import { Socket } from 'vue-socket.io-extended' // v4
import Socket from 'vue-socket.io-extended/decorator' // v5

could you check whether it works this way?

ReazerDev commented 3 years ago

Are you sure you're using alpha5? Newest I can found is alpha4. And there everything is working for me using @socket Decorator. Maybe you could provide some more context of your code. The first thing I would think of is the import of Socket. Maybe it's not correct.

Nope I've been using alpha-4. I'm updating to alpha-5 now.

ReazerDev commented 3 years ago

image Now I get this error when compiling.

This is how I import Socket: import Socket from 'vue-socket.io-extended/decorator';

VSCode doesn't throw any errors and I can even Ctrl+Right-Click it and it finds the type definitions. I've deleted my node_modules folder and my package-lock.json.

This is in my package.json: "vue-socket.io-extended": "^5.0.0-alpha.5"

probil commented 3 years ago

@ReazerDev That's weird. How are use transpiling TS in vue files? With typescript or babel? Or maybe something more cutting edge, e.g. esbuild?

ReazerDev commented 3 years ago

I'm using babel

jnt0r commented 3 years ago

I just updated to alpha.5 and it's working for me. Think I'm using babel too. @ReazerDev can you share a link to your repo or provide some snippets of your config?

ReazerDev commented 3 years ago

I'll push the repo to Github and post a link here, once I'm home👍

ReazerDev commented 3 years ago

https://github.com/ReazerDev/vue-3-socket-io-demo

jnt0r commented 3 years ago

@ReazerDev got your repo working. Just updated the dependencies to the newest ones. Especially the ones with "@vue/...".

ReazerDev commented 3 years ago

Wait I think I just now realised, that you mean, that everything is working and not that you got my repo working and are starting to look what causes my issue?

jnt0r commented 3 years ago

No. I meant that I got your repo working by updating the dependencies. You need to update the dependencies with "@vue/..." to get your repo working.