Due to the limitation of TS, prop validator must be fully annotated
refer to https://github.com/microsoft/TypeScript/issues/38623
eee: () => { a: string }
fff: (a: number, b: string) => { a: boolean }
hhh: boolean
+ validated?: string
}
type GT = string & { __brand: unknown }
hhh: {
type: Boolean,
required: true
+ },
+ validated: {
+ type: String,
+ validator: (val: unknown) => val !== ''
}
},
setup(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))