| { (): T }
| PropMethod<T>
-type PropMethod<T, TConstructor = any> = [T] extends [(...args: any) => any] // if is function with args
+type PropMethod<T, TConstructor = any> = [T] extends [
+ ((...args: any) => any) | undefined
+] // if is function with args, allowing non-required functions
? { new (): TConstructor; (): T; readonly prototype: TConstructor } // Create Function like constructor
: never
b: string
e?: Function
h: boolean
+ j: undefined | (() => string | undefined)
bb: string
bbb: string
bbbb: string | undefined
},
e: Function,
h: Boolean,
+ j: Function as PropType<undefined | (() => string | undefined)>,
// default value should infer type and make it non-void
bb: {
default: 'hello'
expectType<ExpectedProps['b']>(props.b)
expectType<ExpectedProps['e']>(props.e)
expectType<ExpectedProps['h']>(props.h)
+ expectType<ExpectedProps['j']>(props.j)
expectType<ExpectedProps['bb']>(props.bb)
expectType<ExpectedProps['bbb']>(props.bbb)
expectType<ExpectedProps['bbbb']>(props.bbbb)