Skip to content

Translated to TypeScript and fixed issue with IAsyncComputedValue<T> #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2020
Merged

Conversation

firefligher
Copy link
Contributor

@firefligher firefligher commented Jan 11, 2020

Hi,
my original issue was that if I pass options to the AsyncComputed decorator function, the get property of the passed options object supersedes the decorated function. Also, since the get property of the IAsyncComputedValue<T> interface is mandatory, I cannot circumvent this behavior by simply not specifying this property (at least when using a strict TypeScript configuration).

I fixed this issue by implementing a second interface IAsyncComputedOptions<TResult>, which does not provide a get property at all (because I think it does not make very much sense here). I am not really happy with this fix because it requires updating the new interface each time you modify the IAsyncComputedValue<T> interface in the vue-async-computed package, but it was the best I could come up with.

I also translated the project to TypeScript as requested here. I adjusted the configuration files as needed, but I have no clue about Travis CI, so you should check out, if that configuration needs to be modified as well.

Since my mother tongue is not English, I also hope that I have not made too many mistakes in the documentation comments 😁.

Cheers.

@foxbenjaminfox
Copy link
Owner

Thanks, this is a great PR.

I'm going to merge this, although I haven't gone over the details of the build tooling changes here yet. I might tweak them a bit first, but I will soon release this as a new version of this package.

I think it's worth considering putting the IAsyncComputedOptions in vue-async-computed itself. It doesn't harm anything for it to be there (exported from index.d.ts), and that means we can define IAsyncComputedValue extending it. (That is to say, we'd have export interface IAsyncComputedValue<T> extends IAsyncComputedOptions<T> { get: AsyncComputedGetter<T>; } as the definition for IAsyncComputedValue.)

This would remove all the duplication. I don't mind adding IAsyncComputedOptions to vue-async-computed even though most people wouldn't need to use it because after all, it's just a type, not anything that needs to run at runtime.

Then we'd re-export the type from vue-async-computed-decorator, instead of defining it here.

What do you think about this?

@foxbenjaminfox foxbenjaminfox merged commit 265b9b2 into foxbenjaminfox:master Jan 12, 2020
@firefligher
Copy link
Contributor Author

Yeah, that's probably the best approach to keep everything nice and clean 😅. I also thought about this, but I did not want to make too many modifications in multiple projects as some maintainers do not like this very much. I'll have a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants