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

Please remove dependency on vue-class-component for Typescript users...

Open rfox12 opened this issue 5 years ago • 7 comments

I love this library--it's been useful. Now that all my projects are Typescript I've noticed that this library is complaining that I need vue-class-component... but I don't need it for my setup (I use the new Vue Composition API).

It seems that index.d.ts uses VueDecorator in exactly one line. Is there any easy way to separate that out?

rfox12 avatar May 24 '20 17:05 rfox12

Hi @rfox12 👋 Thanks for good words. I'm glad that library helps someone

Interesting claim I can tell you. 🤔 This is a bit strange because compiled library should not depend on vue-class-component anyhow. If you don't import Socket it should not bother you. But yeah, typescript sometimes is a bit "over-typed".

This is not the only issue I've got with the decorator. I had another problem with mixing default and named export which I thought was solved but it's not.

I guess it's time to move the decorator to a separate library. I think it will solve a bunch of problems. What do you think? I'm not sure just yet whether it's possible or not but I hope so ;)

BTW Are you using Vue 3 or just Composition API? Any ideas on how this library can benefit from composition API?

probil avatar May 24 '20 21:05 probil

I'm using the Composition API as a plug-in for now (w/Vue 2.6). Vuex 4 just came out, but as far as I can tell you shouldn't really need to change anything with vue-socket.io-extended. More Typescript will continue to come to Vue now. When Vuex 5 hits you'll probably need to change some things around to keep the library going. I'll let you know if I run into issues.

rfox12 avatar May 25 '20 01:05 rfox12

Maybe you could move these lines out of index.d.ts and into a new socket.d.ts file?

import { VueDecorator } from 'vue-class-component';

export const Socket: (eventName?: string) => VueDecorator;

rfox12 avatar May 25 '20 01:05 rfox12

I'm not sure whether typescript will start using that file socket.d.ts automatically or not 🤔 I suppose if I import socket.d.ts to index.d.ts the problem won't disappear. They only solution I see is an experiment

@rfox12 if I make a branch with a potential fix would you like to check it?

probil avatar May 25 '20 08:05 probil

This is an issue for me as well. I installed the dependency as a workaround

ChrisAgar avatar Jun 18 '20 08:06 ChrisAgar

same error

guoxiangke avatar Jul 25 '20 08:07 guoxiangke

@rfox12 fixed in alpha of v5, but requires vue 3 for now. Will try to adopt it to work with v2 + composition api plugin https://github.com/probil/vue-socket.io-extended/tree/alpha

probil avatar Jan 25 '21 11:01 probil