Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compile-sfc): support Error type in defineProps #5955

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'>
Expand Down Expand Up @@ -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 },`
)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-sfc/src/script/resolveType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ export function inferRuntimeType(
case 'WeakMap':
case 'Date':
case 'Promise':
case 'Error':
return [node.typeName.name]

// TS built-in utility types
Expand Down