The second approach of using mounted is preferred over the rest of the approaches. The only change I would suggest is the use of created hook instead of mounted:

export default class Test extends Vue {
  protected msg: string = '';

  created() {
    this.msg = 'Today\'s date ' + moment().format('YYYY/MM/DD');
  }
}

Generally, for simple properties, you can directly assign a value at a time of declaration. Use created when your assignment is not simple.

Also, we don't really use constructors when writing the class-based component. The reason behind is that essentially Vue.js components are object-based. The @Component decorator is eventually making the component behave like object-based.

Further, if you look at Vue.js component lifecycle methods, then there is no place for a constructor. The initial methods are beforeCreate -> data -> created -> mounted and so on. How can a beforeCreate execute without an actual call to the constructor? That make is really weird to reason about.

Note 1: For version 3 of Vue.js, official class-based components are proposed. Thus, this might change in the near future.

Note 2: TypeScript will move msg declaration to the constructor after compilation and Vue.js seems to work well with it. But it is still unspecified and better be avoided.

Answer from Harshal Patil on Stack Overflow
🌐
Tessl
tessl.io › registry › tessl › npm-vue-property-decorator
9.1.0 • npm-vue-property-decorator • tessl • Registry • Tessl
January 29, 2026 - Base Exports: Re-exports Vue, Component ... decorators for parent-child communication · Lifecycle Decorators: Watch decorator for reactive data observation...
🌐
GitHub
github.com › kaorun343 › vue-property-decorator
GitHub - kaorun343/vue-property-decorator: Vue.js and Property Decorator · GitHub
February 7, 2024 - The functions decorated by @Emit $emit their return value followed by their original arguments. If the return value is a promise, it is resolved before being emitted. If the name of the event is not supplied via the event argument, the function name is used instead. In that case, the camelCase name will be converted to kebab-case. import { Vue, Component, Emit } from 'vue-property-decorator' @Component export default class YourComponent extends Vue { count = 0 @Emit() addToCount(n: number) { this.count += n } @Emit('reset') resetCount() { this.count = 0 } @Emit() returnValue() { return 10 } @Emit() onInputChange(e) { return e.target.value } @Emit() promise() { return new Promise((resolve) => { setTimeout(() => { resolve(20) }, 0) }) } }
Starred by 5.5K users
Forked by 377 users
Languages   TypeScript 86.7% | JavaScript 13.3%
🌐
npm
npmjs.com › package › vue-property-decorator
vue-property-decorator - npm
The functions decorated by @Emit $emit their return value followed by their original arguments. If the return value is a promise, it is resolved before being emitted. If the name of the event is not supplied via the event argument, the function name is used instead. In that case, the camelCase name will be converted to kebab-case. import { Vue, Component, Emit } from 'vue-property-decorator'
      » npm install vue-property-decorator
    
Published   Nov 20, 2020
Version   9.1.2
Author   kaorun343
🌐
Tessl
tessl.io › registry › tessl › npm-vue-property-decorator › 9.1.0 › files › docs › base-components.md
tessl/npm-vue-property-decorator@9.1.x - Registry - Tessl
import { Vue, Component } from "vue-property-decorator"; // Basic component @Component export default class BasicComponent extends Vue { message = "Hello World"; } // Component with options @Component({ name: "MyCustomComponent", components: { ChildComponent: () => import("./ChildComponent.vue") }, template: ` <div> <h1>{{ title }}</h1> <child-component /> </div> ` }) export default class CustomComponent extends Vue { title = "Custom Component"; } // Component with lifecycle hooks @Component export default class LifecycleComponent extends Vue { data = []; created() { console.log("Component created"); this.fetchData(); } mounted() { console.log("Component mounted"); } beforeDestroy() { console.log("Component will be destroyed"); this.cleanup(); } private async fetchData() { // Fetch data implementation } private cleanup() { // Cleanup implementation } }
🌐
GitHub
github.com › lidessen › vue-class-decorator
GitHub - lidessen/vue-class-decorator: Vue.js and Property Decorator
@Watch (from vue-property-decorator) @Component (from vue-class-component) Mixins (the helper function named mixins defined at vue-class-component) Note: all the lifecycle hooks are supported · import { FunctionalVue, Component, Filter } from 'vue-class-decorator' @Component export default class YourComponent extends FunctionalVue { //... } is equivalent to ·
Author   lidessen
🌐
Lavalite
lavalite.org › blog › using-vuejs-components-based-on-property-decorator
Using Vue.js components based on property decorator - Lavalite
April 1, 2022 - Real time validation using Lifecycle hooks in Laravel Livewire. ... Vue.js, Components, property decorators, vue-property-decorator, standard Vue tool, Web Applications, Web Development,
🌐
Skypack
skypack.dev › view › vue-class-decorator
npm:vue-class-decorator | Skypack
@Watch (from vue-property-decorator) @Component (from vue-class-component) Mixins (the helper function named mixins defined at vue-class-component) Note: all the lifecycle hooks are supported · import { FunctionalVue, Component, Filter } from 'vue-class-decorator' @Component export default class YourComponent extends FunctionalVue { //... } is equivalent to ·
Find elsewhere
🌐
Vuejs
class-component.vuejs.org › guide › custom-decorators.html
Custom Decorators | Vue Class Component
// decorators.js import { createDecorator } from 'vue-class-component' // Declare Log decorator. export const Log = createDecorator((options, key) => { // Keep the original method for later. const originalMethod = options.methods[key] // Wrap the method with the logging logic. options.methods[key] = function wrapperMethod(...args) { // Print a log. console.log(`Invoked: ${key}(`, ...args, ')') // Invoke the original method. originalMethod.apply(this, args) } }) ... import Vue from 'vue' import Component from 'vue-class-component' import { Log } from './decorators' @Component class MyComp extends Vue { // It prints a log when `hello` method is invoked.
🌐
Vuejs
class-component.vuejs.org › api
API Reference | Vue Class Component
See Custom Decorators for more details. The followings are built-in hook names that class components treat as special methods. ... They will not be registered as component methods but (lifecycle) hooks. You should avoid these reserved names when your properties or methods are not supposed to ...
🌐
GitHub
github.com › kaorun343 › vue-property-decorator › issues › 126
@Data decorator · Issue #126 · kaorun343/vue-property-decorator
August 16, 2018 - The current workaround for this is to use a data method in the Component options, since when Vue calls data(), the props are already initialized: @Component({ data() { return { localData: this.data, } }, }) If there was a @Data decorator that would convert something like this: @Data() localData: string = data; to a data method as above, that would make the code cleaner. The text was updated successfully, but these errors were encountered: Copy link · Owner · Isn't it enough to initialize localData, in your example, at created lifecycle hook?
🌐
GitHub
github.com › ztytotoro › vue-class-decorator
GitHub - aoiste/vue-class-decorator: Vue.js and Property Decorator
@Watch (from vue-property-decorator) @Component (from vue-class-component) Mixins (the helper function named mixins defined at vue-class-component) Note: all the lifecycle hooks are supported · import { FunctionalVue, Component, Filter } from 'vue-class-decorator' @Component export default class YourComponent extends FunctionalVue { //... } is equivalent to ·
Forked by 380 users
Languages   TypeScript 86.5% | JavaScript 13.5% | TypeScript 86.5% | JavaScript 13.5%
🌐
egghead.io
egghead.io › lessons › vue-js-define-props-on-a-vue-class-with-vue-property-decorator
Define Props on a Vue Class with vue-property-decorator | egghead.io
[01:01] Delete this on this side, hit save here, and you'll see, "hello from index," because we still have it set in our index file. Delete that, and you'll see, "hello from prop decorator," which we defined right here. [01:15] Now, just to be a bit more terse, vue-property-decorator includes vue-class-component, and re-exports component.
Published   December 13, 2017
🌐
Davidjamesherzog
davidjamesherzog.github.io › 2020 › 12 › 30 › vue-typescript-decorators
Vue.js with Typescript and Decorators | David Herzog
December 29, 2020 - Before we start coding, we need to install the libraries that add decorator support to our project. Here is a list of libraries we will be adding: vue-class-component (opens new window) - used to define components which is installed by default when Typescript Vue 3 project created · vue-property-decorator (opens new window) - used to define props, watches, etc.
🌐
GitHub
github.com › kaorun343 › vue-property-decorator › issues › 294
kaorun343/vue-property-decorator
January 5, 2020 - Vue.js and Property Decorator. Contribute to kaorun343/vue-property-decorator development by creating an account on GitHub.
Author   avxkim
🌐
LogRocket
blog.logrocket.com › home › define properties with vue property decorator and typescript
Define properties with Vue Property Decorator and TypeScript - LogRocket Blog
June 4, 2024 - To solve this issue, the Vue Class Component plugin uses ECMAScript decorators to pass statically typed values directly to components in Vue, making the compiler understand what is happening. In this article, you’ll learn how to define properties like data, methods, computed properties, props, and watchers directly on the class in Vue components by supporting TypeScript in Vue class-based components.
🌐
Joshua1988
joshua1988.github.io › vue-camp › ts › pdecorator.html
Vue Property Decorator | Cracking Vue.js
<!-- Child.vue --> <template> <div class="hello"> <h1>{{ msg }}</h1> </div> </template> <script lang="ts"> import { Vue, Component, Prop } from 'vue-property-decorator'; @Component export default class Child extends Vue { // '!'는 초기화 속성에 붙이는 prefix (타입스크립트에게 미리 알려주는 역할) @Prop() private msg!: string; } </script>
🌐
GitHub
github.com › omi982 › vue-property-decorator
GitHub - omi982/vue-property-decorator: Vue.js and Property Decorator
The functions decorated by @Emit $emit their return value followed by their original arguments. If the return value is a promise, it is resolved before being emitted. If the name of the event is not supplied via the event argument, the function name is used instead. In that case, the camelCase name will be converted to kebab-case. import { Vue, Component, Emit } from 'vue-property-decorator' @Component export default class YourComponent extends Vue { count = 0 @Emit() addToCount(n: number) { this.count += n } @Emit('reset') resetCount() { this.count = 0 } @Emit() returnValue() { return 10 } @Emit() onInputChange(e) { return e.target.value } @Emit() promise() { return new Promise((resolve) => { setTimeout(() => { resolve(20) }, 0) }) } }
Author   omi982
🌐
npm
npmjs.com › package › vue-facing-decorator › v › 1.0.7
vue-facing-decorator - npm
June 8, 2022 - In class lifecycle names · import { Component, Ref, Watch, Prop, Inject, Emit, Base, } from "vue-facing-decorator"; import AnotherComponent from "./AnotherComponent.vue"; //super class. See extends section. class Sup extends Base { //reactivity super property supProperty = "supProperty"; //super method supMethod() {} //super getter get supGetter() { return "supGetter"; } } //component class @Component({ //OPTION, component name name: "MyComponent", //OPTION, emits emits: ["update:modelValue"], //OPTION, provide object or function(this:Comp){return {foo:'bar'}} provide: { provideKey: "provideV
      » npm install vue-facing-decorator
    
Published   May 24, 2025
Version   1.0.7
🌐
Vuejs
class-component.vuejs.org › guide › class-component.html
Class Component | Vue Class Component
import Vue from 'vue' import Component from 'vue-class-component' @Component export default class HelloWorld extends Vue { // Declare mounted lifecycle hook mounted() { console.log('mounted') } // Declare render function render() { return <div>Hello World!</div> } } For all other options, pass them to the decorator function: <template> <OtherComponent /> </template> <script> import Vue from 'vue' import Component from 'vue-class-component' import OtherComponent from './OtherComponent.vue' @Component({ // Specify `components` option.