So I have a class and interface declared with the same name.
declare module "mongoose"
{
class Schema<T = any>
{
constructor(definition?: SchemaDefinition);
}
interface Schema<T = any>
{
new(definition?: TypedSchemaDefinition<T>): Schema<T>;
}
}
Let assume that TypedSchemaDefinition
just converts the type parameter props into their run-time counterpart. I'm not going to include all the code that does achieves this functionality for simplicity purpose unless its required.
Example props: compile type => runtime type & string => String & number => Number etc...
This should not throw an error.
interface ShippingCompileType {
days: number,
price: number,
}
const ShippingRuntimeType: TypedSchemaDefinition<ShippingCompileType> = {
days: Number,
price: Number,
}
const ShippingSchema = new Schema(ShippingRuntimeType);
Error: TypedSchemaDefinition<ShippingCompileType> is not assignable to SchemaDefinition
I don't know if this is a bug or an intended feature, because mixins and declaration merging should merge the two constructor type and allow ShippingRuntimeType
as a valid parameter of the function. If this is a bug, then is there a work around??
Just delete .vs file and add the file into the type root in order to fix the typescript modules IntelliSense.