A
A
Alexey Nikolaev2019-10-30 10:50:05
typescript
Alexey Nikolaev, 2019-10-30 10:50:05

How to type the contents of $options?

Good day.
The $options object in Vue is typed as a VueOptions object (something similar) that holds string keys and any values.
I'm looking for a way to limit the types of data available for saving to this object, so that you can't throw anything - firstly, and so that when you hover over a line like this.$options.property in the IDE, the correct property type is highlighted - secondly (now highlighted any, putting a typed property in $options does not solve either of the two problems). To be something like this:

type $options {
   key: string,
   value: GenericOption
};

The question is: how in the declaration file (shims-vue.d.ts) to get close to $options and redefine its type?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2019-10-30
@grinat

Xs how do you write something there, how can these options readonly https://github.com/vuejs/vue/blob/731e4d0ebc997a6c...
Here is an example of how to add
https://github.com/vuejs/vuex/blob/ 65dbfec40d5fe7a...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question