prop: {{ propMessage }}
5 |msg: {{ msg }}
6 |helloMsg: {{ helloMsg }}
7 |computed msg: {{ computedMsg }}
8 |12 | 13 |
14 | 15 |16 | Clicked: {{ count }} times 17 | 18 |
19 |hello times: {{ helloTimes }}
3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /example/src/components/World.tsx: -------------------------------------------------------------------------------- 1 | import Vue, { CreateElement } from 'vue' 2 | import Component from '../../../lib/index' 3 | 4 | @Component 5 | export default class World extends Vue { 6 | render (h: CreateElement) { 7 | returnThis is rendered via TSX
8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/src/main.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import store from './store' 4 | 5 | new Vue({ 6 | el: '#app', 7 | store, 8 | render: h => h(App, { 9 | props: { propMessage: 'World' } 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /example/src/shims-tsx.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VNode } from 'vue' 2 | 3 | declare global { 4 | namespace JSX { 5 | interface Element extends VNode {} 6 | interface ElementClass extends Vue {} 7 | interface IntrinsicElements { 8 | [elem: string]: any 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue' 3 | export default Vue 4 | } 5 | -------------------------------------------------------------------------------- /example/src/store.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | interface CounterState { 5 | count: number 6 | } 7 | 8 | Vue.use(Vuex) 9 | 10 | const state = { 11 | count: 0 12 | } 13 | 14 | const mutations = { 15 | increment (state: CounterState) { 16 | state.count++ 17 | } 18 | } 19 | 20 | export default new Vuex.Store({ 21 | state, 22 | mutations 23 | }) 24 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": [ 5 | "dom", 6 | "esnext" 7 | ], 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "experimentalDecorators": true, 11 | "strict": true, 12 | "noUnusedLocals": true, 13 | "noUnusedParameters": true, 14 | "jsx": "preserve", 15 | "jsxFactory": "h" 16 | }, 17 | "include": [ 18 | "./**/*.ts" 19 | ], 20 | "compileOnSave": false 21 | } 22 | -------------------------------------------------------------------------------- /example/webpack.config.js: -------------------------------------------------------------------------------- 1 | const VueLoaderPlugin = require('vue-loader/lib/plugin') 2 | 3 | module.exports = { 4 | mode: 'development', 5 | context: __dirname, 6 | entry: './src/main.ts', 7 | output: { 8 | path: __dirname, 9 | filename: 'build.js' 10 | }, 11 | resolve: { 12 | alias: { 13 | vue$: 'vue/dist/vue.esm.js' 14 | }, 15 | extensions: ['.ts', '.tsx', '.js'] 16 | }, 17 | module: { 18 | rules: [ 19 | { 20 | test: /\.tsx?$/, 21 | exclude: /node_modules/, 22 | use: [ 23 | 'babel-loader', 24 | { 25 | loader: 'ts-loader', 26 | options: { 27 | appendTsSuffixTo: [/\.vue$/], 28 | appendTsxSuffixTo: [/\.vue$/] 29 | } 30 | } 31 | ] 32 | }, 33 | { 34 | test: /\.vue$/, 35 | use: ['vue-loader'] 36 | } 37 | ] 38 | }, 39 | devtool: 'source-map', 40 | plugins: [ 41 | new VueLoaderPlugin() 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /hooks.d.ts: -------------------------------------------------------------------------------- 1 | import { VNode } from 'vue' 2 | 3 | declare module 'vue/types/vue' { 4 | interface Vue { 5 | data?(): object 6 | beforeCreate?(): void 7 | created?(): void 8 | beforeMount?(): void 9 | mounted?(): void 10 | beforeDestroy?(): void 11 | destroyed?(): void 12 | beforeUpdate?(): void 13 | updated?(): void 14 | activated?(): void 15 | deactivated?(): void 16 | render?(createElement: CreateElement): VNode 17 | errorCaptured?(err: Error, vm: Vue, info: string): boolean | undefined 18 | serverPrefetch?(): Promise