给定一个Typescript接口: interface Foo {} 我可以通过索引到接口类型来获取函数的类型: type X = Foo["bar"] // X is (a: string) => Bar 但这不适用于构造签名: interface Foo {}
type X = Foo["new"]
<{ id: number, value: string }>// K will be the type of all the keys of Arraytype like length, toString, ...// I wish the below can make T the type { id: number, value: string }
我在TypeScript中定义了这样一个猫鼬模式。所以我在猫鼬模式中将这个字段定义为"Schema.Types.Mixed“,但是编译器给出了这个错误。Type '{ type: typeof Schema.Types.Mixed; required: true; }' is not assignable to type 'SchemaDefinitionPropertyType 'typeof Mix
BaseClass我想要创建一个接口类型的对象,并将具体的类分配给它。并不认为ConcreteClass1、ConcreteClass2或ConcreteClass3与typeof BaseClass兼容。,TypeScript似乎不允许在typeof Class之后使用泛型参数。对于接口中的每一行,我得到两个错误,如下所示:
Call signature, which lacks return-type a