-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
typescriptTypes or Types-test related issue / Pull RequestTypes or Types-test related issue / Pull Request
Milestone
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
the schema definition must match EXACTLY as the interface in case of array
It does not complain when it is array like this, but if it was an object with type: [HistoryUpdateRecordSchema]
it gives type error!!
Type '{ type: Schema<HistoryUpdateRecord & Document<any>, Model<HistoryUpdateRecord & Document<any>>, HistoryUpdateRecord>[]; default: undefined; }' is not assignable to type 'SchemaDefinitionProperty<Pick<Pick<_LeanDocument<HistoryUpdateRecord>, "fieldName" | "oldValue" | "newValue">, "fieldName" | "oldValue" | "newValue">[]>'.
Types of property 'type' are incompatible.
Type 'Schema<HistoryUpdateRecord & Document<any>, Model<HistoryUpdateRecord & Document<any>>, HistoryUpdateRecord>[]' is not assignable to type 'string | Function | Pick<Pick<_LeanDocument<HistoryUpdateRecord>, "fieldName" | "oldValue" | "newValue">, "fieldName" | "oldValue" | "newValue">[]'.
Type 'Schema<HistoryUpdateRecord & Document<any>, Model<HistoryUpdateRecord & Document<any>>, HistoryUpdateRecord>[]' is not assignable to type 'Pick<Pick<_LeanDocument<HistoryUpdateRecord>, "fieldName" | "oldValue" | "newValue">, "fieldName" | "oldValue" | "newValue">[]'.
Type 'Schema<HistoryUpdateRecord & Document<any>, Model<HistoryUpdateRecord & Document<any>>, HistoryUpdateRecord>' is missing the following properties from type 'Pick<Pick<_LeanDocument<HistoryUpdateRecord>, "fieldName" | "oldValue" | "newValue">, "fieldName" | "oldValue" | "newValue">': fieldName, oldValue, newValue
If the current behavior is a bug, please provide the steps to reproduce.
https://gist.github.com/ahmednaser94/5a6288614fa29eea30f15a7ee1a42a22
{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"outDir": "dist",
"removeComments": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"moduleResolution": "Node",
"sourceMap": true,
"typeRoots": ["@types", "./node_modules/@types"]
},
"include": ["src"],
"exclude": ["test", "node_modules"]
}
What is the expected behavior?
It should not complain about type as any other property
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
"typescript": "^4.1.5",
"mongodb": "^3.6.4",
"mongoose": "^5.11.17",
Metadata
Metadata
Assignees
Labels
typescriptTypes or Types-test related issue / Pull RequestTypes or Types-test related issue / Pull Request