Skip to content

Commit

Permalink
fix(compile-sfc): Support define Error as prop type
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan committed May 19, 2022
1 parent 523f6aa commit 13291f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Expand Up @@ -1521,6 +1521,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 },
union: { type: [String, Number], required: true },
literalUnion: { type: String, required: true },
literalUnionNumber: { type: Number, required: true },
Expand Down
3 changes: 3 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Expand Up @@ -784,6 +784,7 @@ const emit = defineEmits(['a', 'b'])
alias: Alias
method(): void
symbol: symbol
error: Error
union: string | number
literalUnion: 'foo' | 'bar'
Expand Down Expand Up @@ -814,6 +815,7 @@ const emit = defineEmits(['a', 'b'])
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(
`union: { type: [String, Number], required: true }`
)
Expand Down Expand Up @@ -847,6 +849,7 @@ const emit = defineEmits(['a', 'b'])
alias: BindingTypes.PROPS,
method: BindingTypes.PROPS,
symbol: BindingTypes.PROPS,
error: BindingTypes.PROPS,
union: BindingTypes.PROPS,
literalUnion: BindingTypes.PROPS,
literalUnionNumber: BindingTypes.PROPS,
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-sfc/src/compileScript.ts
Expand Up @@ -1811,6 +1811,7 @@ function inferRuntimeType(
case 'WeakMap':
case 'Date':
case 'Promise':
case 'Error':
return [node.typeName.name]
case 'Record':
case 'Partial':
Expand Down

0 comments on commit 13291f5

Please sign in to comment.