1
1
import { ASTConverter , ASTResultKind , ReferenceKind } from '../types'
2
2
import type ts from 'typescript'
3
- import { isPrimitiveType , copySyntheticComments , removeComments } from '../../utils'
3
+ import { copySyntheticComments , removeComments } from '../../utils'
4
4
5
5
export const convertData : ASTConverter < ts . PropertyDeclaration > = ( node , options , program ) => {
6
6
if ( ! node . initializer ) {
@@ -9,31 +9,20 @@ export const convertData: ASTConverter<ts.PropertyDeclaration> = (node, options,
9
9
const tsModule = options . typescript
10
10
const dataName = node . name . getText ( )
11
11
12
- const checker = program . getTypeChecker ( )
13
- const isRef = isPrimitiveType ( tsModule , checker . getTypeAtLocation ( node . initializer ) )
14
-
15
- const tag = ( isRef ) ? 'Data-ref' : 'Data-reactive'
16
- const named = ( isRef ) ? [ 'ref' ] : [ 'reactive' ]
17
- const callExpr = ( isRef )
18
- ? tsModule . createCall (
19
- tsModule . createIdentifier ( 'ref' ) ,
20
- undefined ,
21
- [ removeComments ( tsModule , node . initializer ) ]
22
- )
23
- : tsModule . createCall (
24
- tsModule . createIdentifier ( 'reactive' ) ,
25
- undefined ,
26
- [ removeComments ( tsModule , node . initializer ) ]
27
- )
12
+ const callExpr = tsModule . createCall (
13
+ tsModule . createIdentifier ( 'ref' ) ,
14
+ undefined ,
15
+ [ removeComments ( tsModule , node . initializer ) ]
16
+ )
28
17
29
18
return {
30
- tag,
19
+ tag : 'Data-ref' ,
31
20
kind : ASTResultKind . COMPOSITION ,
32
21
imports : [ {
33
- named,
22
+ named : [ 'ref' ] ,
34
23
external : ( options . compatible ) ? '@vue/composition-api' : 'vue'
35
24
} ] ,
36
- reference : ( isRef ) ? ReferenceKind . VARIABLE_VALUE : ReferenceKind . VARIABLE ,
25
+ reference : ReferenceKind . VARIABLE_VALUE ,
37
26
attributes : [ dataName ] ,
38
27
nodes : [
39
28
copySyntheticComments (
0 commit comments