-
-
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
I don't know if it is a bug. It seems to be so. I can tell you it worked with v5.10.11. It doesn't work anymore with v5.11.16
Given this piece code
function transformOne<T>(document: T & Document): T {
return document.toObject();
}the compiler complaints as follows
Type 'Pick<Pick<_LeanDocument<T & Document<any>>, "_id" | "__v" | "id" | Exclude<keyof T, "$ignore" | "$isDefault" | "$isDeleted" | "$isEmpty" | "$isValid" | ... 46 more ... | "$isSingleNested">>, Exclude<...> | ... 2 more ... | Exclude<...>>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'Pick<Pick<_LeanDocument<T & Document<any>>, "_id" | "__v" | "id" | Exclude<keyof T, "$ignore" | "$isDefault" | "$isDeleted" | "$isEmpty" | "$isValid" | ... 46 more ... | "$isSingleNested">>, Exclude<...> | ... 2 more ... | Exclude<...>>'.ts(2322)
My tsconfig.json is as follows
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
}
}Metadata
Metadata
Assignees
Labels
typescriptTypes or Types-test related issue / Pull RequestTypes or Types-test related issue / Pull Request