vue-rx icon indicating copy to clipboard operation
vue-rx copied to clipboard

Typescript types are incompletes

Open AntoineEsteve opened this issue 6 years ago • 7 comments

Hello,

We are using vue-rx with typescript and we encountered some issues:

  • In subscriptions we can access to the properties defined in data but the current vue-rx types say that we can't.

Note: It works if you use: subscriptions?: Observables | (() => Observables) instead of subscriptions?: Observables | ((this: V) => Observables). But i didn't make a pull request because i am not sure that we can access to the props when subscriptions is called.

  • this is not extended with the data set by the subscriptions. So we can not access to the current values in the methods etc.

AntoineEsteve avatar Jun 28 '18 14:06 AntoineEsteve

I have a same issue

Terry-bear avatar Aug 29 '18 08:08 Terry-bear

Is there a solution?

olivewind avatar Sep 05 '18 03:09 olivewind

I have same issue

ananiy avatar Sep 14 '18 03:09 ananiy

I’m not familiar with ts type definitions, pull requests are welcomed. Or @keego give a check?

regou avatar Sep 14 '18 11:09 regou

So I made a decorator binding lib.

https://github.com/MinuKang/vue-rx-decorators

minuukang avatar Sep 23 '18 11:09 minuukang

I'm also noticing that things like props and methods aren't inferred for the component. Would adding the full set of generics fix this? This is what I mean:

declare module "vue/types/options" {
    interface ComponentOptions<
        V extends Vue,
        Data = DefaultData<V>,
        Methods = DefaultMethods<V>,
        Computed = DefaultComputed,
        PropsDef = PropsDefinition<DefaultProps>,
        Props = DefaultProps
    > {
        subscriptions?: Observables | ((this: V) => Observables);
        domStreams?: string[]
        observableMethods?: string[] | Record<string, string>
    }
}

alexsasharegan avatar May 10 '19 15:05 alexsasharegan

I would like to use $fromDOMEvent('input', 'keyup') inside my class component to have access to properties and methods. Is this possible? Something like this:

export default class MyComponent extends Vue {
.... 
private name;

private handleNameInput(observable: Observable<any>):Observable<any> {
   return observable.pipe(
    ......
   );
 }

 public created() {
   this.handleNameInput($fromDOMEvent('input', 'keyup')).subscribe(
     result => this.name = result
   )
 } 
....
}

raybog avatar Jul 11 '19 10:07 raybog