@@ -53,14 +53,20 @@ const GROUP_COMPUTED_PROPERTY = 'computed'
53
53
const GROUP_METHODS = 'methods'
54
54
const GROUP_SETUP = 'setup'
55
55
const GROUP_WATCHER = 'watch'
56
+ const GROUP_EXPOSE = 'expose'
56
57
57
58
const PROPERTY_LABEL = {
58
59
props : 'property' ,
59
60
data : 'data' ,
60
61
computed : 'computed property' ,
61
62
methods : 'method' ,
62
63
setup : 'property returned from `setup()`' ,
63
- watch : 'watch'
64
+
65
+ // not use
66
+ watch : 'watch' ,
67
+ provide : 'provide' ,
68
+ inject : 'inject' ,
69
+ expose : 'expose'
64
70
}
65
71
66
72
// ------------------------------------------------------------------------------
@@ -900,51 +906,57 @@ module.exports = {
900
906
onVueObjectEnter ( node ) {
901
907
const container = getVueComponentPropertiesContainer ( node )
902
908
903
- for ( const watcher of utils . iterateProperties (
909
+ for ( const watcherOrExpose of utils . iterateProperties (
904
910
node ,
905
- new Set ( [ GROUP_WATCHER ] )
911
+ new Set ( [ GROUP_WATCHER , GROUP_EXPOSE ] )
906
912
) ) {
907
- // Process `watch: { foo /* <- this */ () {} }`
908
- const segments = watcher . name . split ( '.' )
909
- container . usedProperties . addUsed ( segments [ 0 ] , ( context ) => {
910
- return buildChainTracker ( segments ) ( context )
911
- /**
912
- * @param {string[] } baseSegments
913
- * @returns {UsedPropertiesTracker }
914
- */
915
- function buildChainTracker ( baseSegments ) {
916
- return ( ) => {
917
- const subSegments = baseSegments . slice ( 1 )
918
- const usedProps = new UsedProperties ( )
919
- if ( subSegments . length ) {
920
- usedProps . addUsed (
921
- subSegments [ 0 ] ,
922
- buildChainTracker ( subSegments )
923
- )
913
+ if ( watcherOrExpose . groupName === GROUP_WATCHER ) {
914
+ const watcher = watcherOrExpose
915
+ // Process `watch: { foo /* <- this */ () {} }`
916
+ const segments = watcher . name . split ( '.' )
917
+ container . usedProperties . addUsed ( segments [ 0 ] , ( context ) => {
918
+ return buildChainTracker ( segments ) ( context )
919
+ /**
920
+ * @param {string[] } baseSegments
921
+ * @returns {UsedPropertiesTracker }
922
+ */
923
+ function buildChainTracker ( baseSegments ) {
924
+ return ( ) => {
925
+ const subSegments = baseSegments . slice ( 1 )
926
+ const usedProps = new UsedProperties ( )
927
+ if ( subSegments . length ) {
928
+ usedProps . addUsed (
929
+ subSegments [ 0 ] ,
930
+ buildChainTracker ( subSegments )
931
+ )
932
+ }
933
+ return usedProps
924
934
}
925
- return usedProps
926
935
}
927
- }
928
- } )
936
+ } )
929
937
930
- // Process `watch: { x: 'foo' /* <- this */ }`
931
- if ( watcher . type === 'object' ) {
932
- const property = watcher . property
933
- if ( property . kind === 'init' ) {
934
- for ( const handlerValueNode of utils . iterateWatchHandlerValues (
935
- property
936
- ) ) {
937
- if (
938
- handlerValueNode . type === 'Literal' ||
939
- handlerValueNode . type === 'TemplateLiteral'
940
- ) {
941
- const name = utils . getStringLiteralValue ( handlerValueNode )
942
- if ( name != null ) {
943
- container . usedProperties . addUsed ( name , null )
938
+ // Process `watch: { x: 'foo' /* <- this */ }`
939
+ if ( watcher . type === 'object' ) {
940
+ const property = watcher . property
941
+ if ( property . kind === 'init' ) {
942
+ for ( const handlerValueNode of utils . iterateWatchHandlerValues (
943
+ property
944
+ ) ) {
945
+ if (
946
+ handlerValueNode . type === 'Literal' ||
947
+ handlerValueNode . type === 'TemplateLiteral'
948
+ ) {
949
+ const name = utils . getStringLiteralValue ( handlerValueNode )
950
+ if ( name != null ) {
951
+ container . usedProperties . addUsed ( name , null )
952
+ }
944
953
}
945
954
}
946
955
}
947
956
}
957
+ } else if ( watcherOrExpose . groupName === GROUP_EXPOSE ) {
958
+ const expose = watcherOrExpose
959
+ container . usedProperties . addUsed ( expose . name , null )
948
960
}
949
961
}
950
962
container . properties . push ( ...utils . iterateProperties ( node , groups ) )
0 commit comments