-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
BugA bug in TypeScriptA bug in TypeScript
Milestone
Description
Bug Report
π Version & Regression Information
Found in TS v4.8.2.
This is the behavior in every version I tried, and I reviewed the FAQ for entries about
β― Playground Link
Playground link with relevant code
π» Code
// Original Case
declare function foo(obj: { readonly constructor?: any }): void
foo(Object) // Error!!!
declare function bar(obj: { readonly constructor: any }): void;
bar(Object) // OK
π Actual behavior
ObjectConstructor
is not a subtype of { readonly constructor?: any }
, at the same time it is a subtype of a type { readonly constructor: any }
π Expected behavior
In the code above, I expect that type ObjectConstructor
will be a subtype of the object type { readonly constructor?: any }
, because the object use constructor in a covariant way (I can't delete the property inside the function.)
reverofevil
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript