@@ -5,17 +5,20 @@ import {
5
5
type VueLanguagePlugin ,
6
6
replaceSourceRange ,
7
7
} from '@vue/language-core'
8
+ import { ignore } from './core/options'
8
9
9
10
function transform ( {
10
11
codes,
11
12
ast,
12
13
ts,
13
14
source,
15
+ ignore,
14
16
} : {
15
17
codes : Segment < FileRangeCapabilities > [ ]
16
18
ast : import ( 'typescript/lib/tsserverlibrary' ) . SourceFile
17
19
ts : typeof import ( 'typescript/lib/tsserverlibrary' )
18
20
source : 'script' | 'scriptSetup'
21
+ ignore : string [ ]
19
22
} ) {
20
23
function transformArguments (
21
24
argument : import ( 'typescript/lib/tsserverlibrary' ) . Node
@@ -92,12 +95,11 @@ function transform({
92
95
}
93
96
94
97
function walkReactivityFunction (
95
- node : import ( 'typescript/lib/tsserverlibrary' ) . Node ,
96
- parent : import ( 'typescript/lib/tsserverlibrary' ) . Node
98
+ node : import ( 'typescript/lib/tsserverlibrary' ) . Node
97
99
) {
98
100
if ( ts . isCallExpression ( node ) ) {
99
101
if (
100
- / ^ \ $(? ! ( \$ | r e f | c o m p u t e d | s h a l l o w R e f | t o R e f | c u s t o m R e f | d e f i n e P r o p | d e f i n e P r o p s | d e f i n e M o d e l s ) ? $ ) / . test (
102
+ new RegExp ( `^\\ $(?!(\\$| ${ ignore . join ( '|' ) } ) ?$)` ) . test (
101
103
node . expression . getText ( ast )
102
104
)
103
105
) {
@@ -125,13 +127,16 @@ function transform({
125
127
}
126
128
127
129
node . forEachChild ( ( child ) => {
128
- walkReactivityFunction ( child , node )
130
+ walkReactivityFunction ( child )
129
131
} )
130
132
}
131
- ast . forEachChild ( ( child ) => walkReactivityFunction ( child , ast ) )
133
+ ast . forEachChild ( walkReactivityFunction )
132
134
}
133
135
134
- const plugin : VueLanguagePlugin = ( { modules : { typescript : ts } } ) => {
136
+ const plugin : VueLanguagePlugin = ( {
137
+ modules : { typescript : ts } ,
138
+ vueCompilerOptions,
139
+ } ) => {
135
140
return {
136
141
name : 'vue-reactivity-function' ,
137
142
version : 1 ,
@@ -145,6 +150,12 @@ const plugin: VueLanguagePlugin = ({ modules: { typescript: ts } }) => {
145
150
ast : sfc [ source ] ! . ast ,
146
151
ts,
147
152
source,
153
+ ignore : [
154
+ ...ignore ,
155
+ ...( vueCompilerOptions . reactivityFunction ?. ignore || [ ] ) . map (
156
+ ( str ) => str . slice ( 1 )
157
+ ) ,
158
+ ] ,
148
159
} )
149
160
}
150
161
}
0 commit comments