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(types): defineComponent object format with no props type #839

Merged
merged 1 commit into from Nov 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/component/componentOptions.ts
Expand Up @@ -88,7 +88,7 @@ export type ComponentOptionsWithArrayProps<
} & ThisType<ComponentRenderProxy<Props, RawBindings, D, C, M>>

export type ComponentOptionsWithoutProps<
Props = unknown,
Props = {},
RawBindings = Data,
D = Data,
C extends ComputedOptions = {},
Expand Down
4 changes: 2 additions & 2 deletions src/component/defineComponent.ts
Expand Up @@ -17,8 +17,8 @@ export function defineComponent<
C extends ComputedOptions = {},
M extends MethodOptions = {}
>(
options: ComponentOptionsWithoutProps<unknown, RawBindings, D, C, M>
): VueProxy<unknown, RawBindings, D, C, M>
options: ComponentOptionsWithoutProps<{}, RawBindings, D, C, M>
): VueProxy<{}, RawBindings, D, C, M>

// overload 2: object format with array props declaration
// props inferred as { [key in PropNames]?: any }
Expand Down
2 changes: 1 addition & 1 deletion test/types/defineComponent.spec.ts
Expand Up @@ -137,7 +137,7 @@ describe('defineComponent', () => {
const App = defineComponent({
setup(props, ctx) {
isTypeEqual<SetupContext, typeof ctx>(true)
isTypeEqual<unknown, typeof props>(true)
isTypeEqual<{}, typeof props>(true)
return () => null
},
})
Expand Down