-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.2.0
Code with unexpected type error:
export function set<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
return Object.assign(obj, {
[key]: value,
});
}
Expected behavior:
No type errors because K
should is a subtype of keyof T
. It works if key: keyof T
and even key: K & keyof T
.
Actual behavior:
Type error:
A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
kemsky, tcudok, kevinjhanna, devoto13, mernen and 12 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue