Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Augmenting ComponentRenderProxy #249

Copy link
Copy link
Closed
@IlyaSemenov

Description

@IlyaSemenov
Issue body actions

With options API, I used to inject "global" variables into the render context with:

Vue.mixin({
	computed: {
		$store: () => store,
	},
})

declare module 'vue/types/vue' {
	interface Vue {
		$store: Store
	}
}

and then refer to it with:

<template>
  <div>store = {{ $store }}</div>
</template>

How would I do the same with composition API? node_modules/@vue/composition-api/dist/component/component.d.ts seems to be exporting a non-augmentable type ComponentRenderProxy with hardcoded set of properties:

export declare type ComponentRenderProxy<P = {}, S = {}, PublicProps = P> = {
    $data: S;
    $props: PublicProps;
    $attrs: Data;
    $refs: Data;
    $slots: Data;
    $root: ComponentInstance | null;
    $parent: ComponentInstance | null;
    $emit: (event: string, ...args: unknown[]) => void;
} & P & S;

so the template fails to validate:

image

Any ideas?

Also (I'm sure I'm missing something!) why doesn't ComponentRenderProxy simply extend Vue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.