]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compile-sfc): support `Error` type in `defineProps` (#5955)
author木杉 <zhmushan@qq.com>
Mon, 30 Oct 2023 07:45:58 +0000 (15:45 +0800)
committerGitHub <noreply@github.com>
Mon, 30 Oct 2023 07:45:58 +0000 (15:45 +0800)
packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineProps.spec.ts.snap
packages/compiler-sfc/__tests__/compileScript/defineProps.spec.ts
packages/compiler-sfc/src/script/resolveType.ts

index 30e00e518b2665446742421b3be19c60e4d0e208..5b0f96c50147515369c4897693c2566059cfc0c4 100644 (file)
@@ -232,6 +232,7 @@ export default /*#__PURE__*/_defineComponent({
     alias: { type: Array, required: true },
     method: { type: Function, required: true },
     symbol: { type: Symbol, required: true },
+    error: { type: Error, required: true },
     extract: { type: Number, required: true },
     exclude: { type: [Number, Boolean], required: true },
     uppercase: { type: String, required: true },
index 43f54b0aa1e8b1e07f8c654d515bce89625d55e2..674d697a5978db96c893c64825116f5d785654b6 100644 (file)
@@ -97,6 +97,7 @@ const props = defineProps({ foo: String })
       alias: Alias
       method(): void
       symbol: symbol
+      error: Error
       extract: Extract<1 | 2 | boolean, 2>
       exclude: Exclude<1 | 2 | boolean, 2>
       uppercase: Uppercase<'foo'>
@@ -143,6 +144,7 @@ const props = defineProps({ foo: String })
     expect(content).toMatch(`alias: { type: Array, required: true }`)
     expect(content).toMatch(`method: { type: Function, required: true }`)
     expect(content).toMatch(`symbol: { type: Symbol, required: true }`)
+    expect(content).toMatch(`error: { type: Error, required: true }`)
     expect(content).toMatch(
       `objectOrFn: { type: [Function, Object], required: true },`
     )
@@ -198,6 +200,7 @@ const props = defineProps({ foo: String })
       alias: BindingTypes.PROPS,
       method: BindingTypes.PROPS,
       symbol: BindingTypes.PROPS,
+      error: BindingTypes.PROPS,
       objectOrFn: BindingTypes.PROPS,
       extract: BindingTypes.PROPS,
       exclude: BindingTypes.PROPS,
index 215081dc0b76477e50c218855f83dfa346116100..229bb3acfae3635b539b671b90b0464becafc9fb 100644 (file)
@@ -1391,6 +1391,7 @@ export function inferRuntimeType(
             case 'WeakMap':
             case 'Date':
             case 'Promise':
+            case 'Error':
               return [node.typeName.name]
 
             // TS built-in utility types