Open
Description
π Search Terms
covariance
π Version & Regression Information
Checked on 5.8.3 and nightly, showing error.
β― Playground Link
π» Code
export type AddQuestionMarks<T extends object> = {
[K in keyof T as undefined extends T[K] ? never : K]: T[K]
} & {
[K in keyof T as undefined extends T[K] ? K : never]?: T[K]
}
export class Shape<out O extends object> {
declare _output: O
}
// AddQuestionMarks produces covariant, but compiler doesn't think so
export class A<out S extends Shape> {
declare _output: AddQuestionMarks<S['_output']>
}
π Actual behavior
I'm new to the whole variance thing, but it seems like compiler can't properly determine it in this case, AddQuestionMarks
ruins covariance, despite it shouldn't.
If I'm wrong, any explanation would be great. If you have any suggestions on how to implement AddQuestionMarks
in different way without ruining covariance, let me know as well.
π Expected behavior
Result of AddQuestionMarks should be compatible with covariance or we should be able to explicitly set out
on this type.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels