vue-socket.io-extended icon indicating copy to clipboard operation
vue-socket.io-extended copied to clipboard

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

Open ReazerDev opened this issue 3 years ago • 13 comments

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

ReazerDev avatar May 06 '21 18:05 ReazerDev

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 avatar May 12 '21 17:05 jnt0r

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

jnt0r avatar May 12 '21 17:05 jnt0r

@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?

probil avatar May 13 '21 10:05 probil

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 avatar May 14 '21 20:05 ReazerDev

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"

ReazerDev avatar May 14 '21 20:05 ReazerDev

@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?

probil avatar May 15 '21 17:05 probil

I'm using babel

ReazerDev avatar May 15 '21 17:05 ReazerDev

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?

jnt0r avatar May 15 '21 17:05 jnt0r

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

ReazerDev avatar May 15 '21 19:05 ReazerDev

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

ReazerDev avatar May 15 '21 20:05 ReazerDev

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

jnt0r avatar May 16 '21 04:05 jnt0r

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?

ReazerDev avatar Jul 14 '21 15:07 ReazerDev

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.

jnt0r avatar Jul 15 '21 18:07 jnt0r