vue typescript prop as code example

Example 1: vue 3 setup props typescript

import FlashInterface from '@/interfaces/FlashInterface';
import { ref,PropType } from 'vue';
import { useStore } from 'vuex';

export default {
    props: {
        message: {
            type: Object as PropType<FlashInterface>,
            required: true
        }
    },
    setup(props): Record<string, unknown> {
            // Stuff
        }
};

Example 2: props vue typescript

<script>
// you need npm i vue-property-decorator
import { Component, Prop, Vue } from 'vue-property-decorator'
@Component
export default class HelloWorld extends Vue {
  @Prop() readonly msg!: string
  @Prop({default: 'John doe'}) readonly name: string
  @Prop({required: true}) readonly age: number
  @Prop(String) readonly address: string
  @Prop({required: false, type: String, default: 'Developer'}) readonly job: string
}
</script>