Procházet zdrojové kódy

fix(runtime-core): keep options API typing intact when expose is used (#14118)

Fixed: #14117
Fixed: vuejs/language-tools#5069
SerKo před 5 měsíci
rodič
revize
8f82f23846

+ 35 - 0
packages-private/dts-test/defineComponent.test-d.tsx

@@ -2107,3 +2107,38 @@ defineComponent({
     expectType<string>(this.$props)
   },
 })
+
+// #14117
+defineComponent({
+  setup() {
+    const setup1 = ref('setup1')
+    const setup2 = ref('setup2')
+    return { setup1, setup2 }
+  },
+  data() {
+    return {
+      data1: 1,
+    }
+  },
+  props: {
+    props1: {
+      type: String,
+    },
+  },
+  methods: {
+    methods1() {
+      return `methods1`
+    },
+  },
+  computed: {
+    computed1() {
+      this.setup1
+      this.setup2
+      this.data1
+      this.props1
+      this.methods1()
+      return `computed1`
+    },
+  },
+  expose: ['setup1'],
+})

+ 1 - 1
packages/runtime-core/src/apiDefineComponent.ts

@@ -272,7 +272,7 @@ export function defineComponent<
         Slots,
         LocalComponents,
         Directives,
-        Exposed
+        string
       >
     >,
 ): DefineComponent<

+ 2 - 2
packages/runtime-core/src/componentOptions.ts

@@ -1194,7 +1194,7 @@ export type ComponentOptionsWithoutProps<
       S,
       LC,
       Directives,
-      Exposed
+      string
     >
   >
 
@@ -1256,7 +1256,7 @@ export type ComponentOptionsWithArrayProps<
       S,
       LC,
       Directives,
-      Exposed
+      string
     >
   >