-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.2.2
Code
interface Errors {
[field: string]: {
key: string
message: string
}
}
const errors: Errors = {}
function genericObjectFunction<K extends string, V>(obj: Record<K, V>): [K, V][] {
return []
}
/*
Argument of type 'Errors' is not assignable to parameter of type 'Record<string, never>'.
Index signatures are incompatible.
Type '{ key: string; message: string; }' is not assignable to type 'never'.
*/
genericObjectFunction(errors)The types seem generally compatible though, as expected this is legal:
const errorRecord: Record<string, { key: string, message: string }> = errorsExpected behavior:
genericObjectFunction(errors) should compile.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript