@@ -53,14 +53,20 @@ const GROUP_COMPUTED_PROPERTY = 'computed'
5353const GROUP_METHODS = 'methods'
5454const GROUP_SETUP = 'setup'
5555const GROUP_WATCHER = 'watch'
56+ const GROUP_EXPOSE = 'expose'
5657
5758const PROPERTY_LABEL = {
5859 props : 'property' ,
5960 data : 'data' ,
6061 computed : 'computed property' ,
6162 methods : 'method' ,
6263 setup : 'property returned from `setup()`' ,
63- watch : 'watch'
64+
65+ // not use
66+ watch : 'watch' ,
67+ provide : 'provide' ,
68+ inject : 'inject' ,
69+ expose : 'expose'
6470}
6571
6672// ------------------------------------------------------------------------------
@@ -900,51 +906,57 @@ module.exports = {
900906 onVueObjectEnter ( node ) {
901907 const container = getVueComponentPropertiesContainer ( node )
902908
903- for ( const watcher of utils . iterateProperties (
909+ for ( const watcherOrExpose of utils . iterateProperties (
904910 node ,
905- new Set ( [ GROUP_WATCHER ] )
911+ new Set ( [ GROUP_WATCHER , GROUP_EXPOSE ] )
906912 ) ) {
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
924934 }
925- return usedProps
926935 }
927- }
928- } )
936+ } )
929937
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+ }
944953 }
945954 }
946955 }
947956 }
957+ } else if ( watcherOrExpose . groupName === GROUP_EXPOSE ) {
958+ const expose = watcherOrExpose
959+ container . usedProperties . addUsed ( expose . name , null )
948960 }
949961 }
950962 container . properties . push ( ...utils . iterateProperties ( node , groups ) )
0 commit comments