type Class<P> = {__vueNew__(): P } | { new(...args: any[]): P & object }
type Prop<P> = Class<P> | {type: Class<P>, default?: P}
type Props<T> = {[K in keyof T]: Prop<T[K]>}
function getProps<T>(t: Props<T>): T {
return null as any
}
interface StringConstructor {
__vueNew__(): string
}
class Test {
private testTag: string
}
var a = getProps({
test: String,
make: {
type: String,
default: 'ewewew'
},
wtf: Test
})
function needStr(a: string) {}
needStr(a.make)
a.make.charAt
The most interesting thing is the { new(...args: any[]): P & object }, the object typing makes TSC abstain from inferring String instead of string.
Today I found a interesting solution:
The most interesting thing is the
{ new(...args: any[]): P & object }
, theobject
typing makes TSC abstain from inferringString
instead ofstring
.It could fix https://github.com/HerringtonDarkholme/av-ts/issues/59 https://github.com/HerringtonDarkholme/av-ts/issues/21