typescript vue 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: typescript for vue
// tsconfig.json
{
"compilerOptions": {
// this aligns with Vue's browser support
"target": "es5",
// this enables stricter inference for data properties on `this`
"strict": true,
// if using webpack 2+ or rollup, to leverage tree shaking:
"module": "es2015",
"moduleResolution": "node"
}
}