Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Getting typescript error when using Mixed
type
export interface IPatient {
birthday?: string | Date;
}
export const patientSchema = new Schema<IPatient>({
birthday: {
type: SchemaTypes.Mixed
}
});
Type '{ type: typeof Schema.Types.Mixed; }' is not assignable to type 'SchemaDefinitionProperty<string | Date>'. Types of property 'type' are incompatible. Type 'typeof Mixed' is not assignable to type '"string" | StringConstructor | "String" | typeof String | typeof NativeDate | "date" | "Date" | typeof Date'. Type 'typeof Mixed' is missing the following properties from type 'StringConstructor': fromCharCode, fromCodePoint, rawts(2322)
If the current behavior is a bug, please provide the steps to reproduce.
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "src/types/*"]
}
},
"include": ["src/**/*"]
}
What is the expected behavior?
Mixed should behave as any type (sometimes I can't use mongoose types but I still want to use typescript types
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 6.0.11
typescript 4.4.4