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: defineComponent() with array props #364

Merged
merged 7 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update test
  • Loading branch information
antfu committed Jun 10, 2020
commit e1671b7ab591004f7e9cd8e4ad9a5a55bd3ec811
2 changes: 1 addition & 1 deletion src/component/componentProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type Prop<T> = PropOptions<T> | PropType<T>;

type DefaultFactory<T> = () => T | null | undefined;

interface PropOptions<T = any> {
export interface PropOptions<T = any> {
type?: PropType<T> | true | null;
required?: boolean;
default?: T | DefaultFactory<T> | null | undefined;
Expand Down
4 changes: 4 additions & 0 deletions test/types/defineComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ describe('defineComponent', () => {
setup(props) {
props.p1;
props.p2;
type PropsType = typeof props;
isSubType<{ p1: any; p2: any }, PropsType>(true);
isSubType<PropsType, { p1: any; p2: any }>(true);
},
});
new Vue(App);
expect.assertions(2);
});

it('infer the required prop', () => {
Expand Down