Vue-class-component: Public static class properties/methods

Created on 18 Jan 2017  路  4Comments  路  Source: vuejs/vue-class-component

Hello! Thank you for your job. Is it possible to use typescript static properties? For example getter/setter:

public static get StaticProp()

I've tried it, but after decoration I've lost static props.

question

Most helpful comment

That's almost true. vue-class-component is just an API wrapper for Vue, providing type checking mechanism and class style feeling for users.

All 4 comments

This is because vue-class-component is just a syntactic sugar of vue.
Your class after decoration is basically the same as:

var Class = Vue.extend({
  // definition
})

So your static properties are lost.

@HerringtonDarkholme , thank you for quick answer. So in vue we don't have something like react tsx files, when we can create full ts class like:

export class MyComponent extends React.Component<any, any> ...

And we just have Vue Component with type cheking for ts compiler. Am I right?

That's almost true. vue-class-component is just an API wrapper for Vue, providing type checking mechanism and class style feeling for users.

@HerringtonDarkholme , ok it is clear now. Thank you.

Was this page helpful?
0 / 5 - 0 ratings