13
13
- [ Installation] ( #Installation )
14
14
- [ Usage] ( #Usage )
15
15
- [ TypeScript] ( #TypeScript )
16
+ - [ TSX] ( #tsx )
16
17
- [ Limitations] ( #Limitations )
17
18
- [ API] ( https://vue-composition-api-rfc.netlify.com/api.html )
18
19
- [ Changelog] ( https://github.com/vuejs/composition-api/blob/master/CHANGELOG.md )
@@ -54,7 +55,9 @@ After installing the plugin you can use the [Composition API](https://vue-compos
54
55
55
56
# TypeScript
56
57
57
- ** Please upgrade to the latest TypeScript. If you are using vetur, make sure to set ` vetur.useWorkspaceDependencies ` to ` true ` .**
58
+ We provide an Example [ Repository] ( https://github.com/liximomo/vue-composition-api-tsx-example ) with TS and TSX support to help you start.
59
+
60
+ ** This plugin requires TypeScript version >3.5.1. If you are using vetur, make sure to set ` vetur.useWorkspaceDependencies ` to ` true ` .**
58
61
59
62
To let TypeScript properly infer types inside Vue component options, you need to define components with ` createComponent ` :
60
63
@@ -71,6 +74,31 @@ const Component = {
71
74
};
72
75
```
73
76
77
+ ## TSX
78
+
79
+ To support TSX, create a declaration file with following content in your project.
80
+
81
+ ``` ts
82
+ // file: shim-tsx.d.ts
83
+ import Vue , { VNode } from ' vue' ;
84
+ import { ComponentRenderProxy } from ' @vue/composition-api' ;
85
+
86
+ declare global {
87
+ namespace JSX {
88
+ // tslint:disable no-empty-interface
89
+ interface Element extends VNode {}
90
+ // tslint:disable no-empty-interface
91
+ interface ElementClass extends ComponentRenderProxy {}
92
+ interface ElementAttributesProperty {
93
+ $props: any ; // specify the property name to use
94
+ }
95
+ interface IntrinsicElements {
96
+ [elem : string ]: any ;
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
74
102
# Limitations
75
103
76
104
## ` Ref ` Unwrap
@@ -150,10 +178,10 @@ b.list[1].count === 1; // true
150
178
## Template Refs
151
179
152
180
> :white_check_mark :
153
- Support   ;  ;  ;  ; :x : Not Supported
181
+ > Support   ;  ;  ;  ; :x : Not Supported
154
182
155
183
:white_check_mark :
156
- String ref && return it from ` setup() ` :
184
+ String ref && return it from ` setup() ` :
157
185
158
186
``` html
159
187
<template >
@@ -179,7 +207,7 @@ b.list[1].count === 1; // true
179
207
```
180
208
181
209
:white_check_mark :
182
- String ref && return it from ` setup() ` && Render Function / JSX:
210
+ String ref && return it from ` setup() ` && Render Function / JSX:
183
211
184
212
``` jsx
185
213
export default {
0 commit comments