-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.1.4
function test1<O>(): Partial<O> {
return {};
}
function test2<O extends Object>(): Partial<O> {
return {};
}
function test3<O extends {}>(): Partial<O> {
return {};
}
Expected behavior:
No errors.
Actual behavior:
Type '{}' is not assignable to type 'Partial<O>'.
Since Partial
makes every property optional, we should expect {}
to be assignable to every Partial<O>
, regardless of what the generic type O
is.
Random speculation: Is this intended behavior because O
could include required properties on its prototype that aren't on {}
, even if all of the properties on O
itself are optional? If that's the case, is there a way to specify that we don't care about the prototype's properties?
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript