Skip to content

Commit a989345

Browse files
authoredOct 30, 2023
fix(compile-sfc): support Error type in defineProps (#5955)
1 parent 72fdafa commit a989345

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed
 

‎packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineProps.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export default /*#__PURE__*/_defineComponent({
232232
alias: { type: Array, required: true },
233233
method: { type: Function, required: true },
234234
symbol: { type: Symbol, required: true },
235+
error: { type: Error, required: true },
235236
extract: { type: Number, required: true },
236237
exclude: { type: [Number, Boolean], required: true },
237238
uppercase: { type: String, required: true },

‎packages/compiler-sfc/__tests__/compileScript/defineProps.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const props = defineProps({ foo: String })
9797
alias: Alias
9898
method(): void
9999
symbol: symbol
100+
error: Error
100101
extract: Extract<1 | 2 | boolean, 2>
101102
exclude: Exclude<1 | 2 | boolean, 2>
102103
uppercase: Uppercase<'foo'>
@@ -143,6 +144,7 @@ const props = defineProps({ foo: String })
143144
expect(content).toMatch(`alias: { type: Array, required: true }`)
144145
expect(content).toMatch(`method: { type: Function, required: true }`)
145146
expect(content).toMatch(`symbol: { type: Symbol, required: true }`)
147+
expect(content).toMatch(`error: { type: Error, required: true }`)
146148
expect(content).toMatch(
147149
`objectOrFn: { type: [Function, Object], required: true },`
148150
)
@@ -198,6 +200,7 @@ const props = defineProps({ foo: String })
198200
alias: BindingTypes.PROPS,
199201
method: BindingTypes.PROPS,
200202
symbol: BindingTypes.PROPS,
203+
error: BindingTypes.PROPS,
201204
objectOrFn: BindingTypes.PROPS,
202205
extract: BindingTypes.PROPS,
203206
exclude: BindingTypes.PROPS,

‎packages/compiler-sfc/src/script/resolveType.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,7 @@ export function inferRuntimeType(
13911391
case 'WeakMap':
13921392
case 'Date':
13931393
case 'Promise':
1394+
case 'Error':
13941395
return [node.typeName.name]
13951396

13961397
// TS built-in utility types

0 commit comments

Comments
 (0)
Please sign in to comment.