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

fix(runtime-core): InjectionKey compatible with symbol type #3118

Closed
wants to merge 1 commit into from

Conversation

cexbrayat
Copy link
Member

The current type of InjectionKey does not allow to use it as an ES computed property.
This is problematic as the API of mount in VTU lets you add providers with provide: { key: value }.
If you want to use a key defined as:

export const storeKey: InjectionKey<Store<State>> = Symbol();

Then you currently have to cast the key as symbol:

const wrapper = mount(App, { global: { provide: { [storeKey as symbol]: store } } });

This commit allows to use:

const wrapper = mount(AppWithVuex, { global: { provide: { [storeKey]: store } } });

The current type of `InjectionKey` does not allow to use it as an ES computed property.
This is problematic as the API of `mount` in VTU lets you add providers with `provide: { key: value }`.
If you want to use a key defined as:

    export const storeKey: InjectionKey<Store<State>> = Symbol();

Then you currently have to cast the key as symbol:

    const wrapper = mount(App, { global: { provide: { [storeKey as symbol]: store } } });

This commit allows to use:

    const wrapper = mount(AppWithVuex, { global: { provide: { [storeKey]: store } } });
@cexbrayat cexbrayat closed this Jan 28, 2021
@cexbrayat cexbrayat deleted the fix/injection-key-type branch January 28, 2021 16:33
@SimonSimCity
Copy link

Seems this has been picked up again in #5089

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