Skip to content

test(types): add prop validator test #1769

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

Merged
merged 1 commit into from
Aug 14, 2020
Merged
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
6 changes: 6 additions & 0 deletions test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('with object props', () => {
eee: () => { a: string }
fff: (a: number, b: string) => { a: boolean }
hhh: boolean
validated?: string
}

type GT = string & { __brand: unknown }
Expand Down Expand Up @@ -75,6 +76,10 @@ describe('with object props', () => {
hhh: {
type: Boolean,
required: true
},
validated: {
type: String,
validator: (val: unknown) => val !== ''
}
},
setup(props) {
Expand All @@ -92,6 +97,7 @@ describe('with object props', () => {
expectType<ExpectedProps['eee']>(props.eee)
expectType<ExpectedProps['fff']>(props.fff)
expectType<ExpectedProps['hhh']>(props.hhh)
expectType<ExpectedProps['validated']>(props.validated)

// @ts-expect-error props should be readonly
expectError((props.a = 1))
Expand Down