Skip to content
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

inject returning wrong type when using treatDefaultAsFactory #866

Closed
johannes-z opened this issue Dec 2, 2021 · 2 comments
Closed

inject returning wrong type when using treatDefaultAsFactory #866

johannes-z opened this issue Dec 2, 2021 · 2 comments

Comments

@johannes-z
Copy link

johannes-z commented Dec 2, 2021

The type returned from inject resolves to the factory function, rather than the object returned from the factory. For example:

const value = inject('key', () => 1, true)

This type of value is () => 1 instead of 1.

The typescript signature for the function should be:

declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T | (() => T), treatDefaultAsFactory?: boolean): T;
                                                                         ^^^^^^^^^^^^

I changed this in vue-composition-api.d.ts and it works as expected.

@MinatoHikari
Copy link
Contributor

I have found this difference when coding computed-inject for vueuse, let me fix it.

@xiaoxiangmoe
Copy link
Collaborator

fixed in v1.4.4

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

No branches or pull requests

3 participants