I recently developed a Vue plugin that allows me to easily access constant objects in the templates of .vue files using shortcuts:
<template>
<span>{{ $consts.HELLO }}</span>
</template>
export default {
constants: {HELLO: 'hello there!'},
};
The $consts
mentioned above is essentially a reference to $options.constants
.
Now, I am trying to describe this functionality in TypeScript and here is my version:
declare module 'vue/types/vue' {
interface Vue {
readonly constants?: object
readonly $consts: Vue['$options']['?constants'] // ???
}
}
However, when I try to implement this in TypeScript, I encounter the following error:
TS2339: Property '?constants' does not exist on type 'ComponentOptions , DefaultMethods , DefaultComputed, PropsDefinition >, Record...>>'.