-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
TypeScript Version:
3.5, 4.0.0-beta
Search Terms:
mapped object type, readonly property, exclude, lookup type
Code
type MyOmit<T, K extends keyof T> = {
[S in Exclude<keyof T, K>]: T[S]
}
declare const foo: MyOmit<{ readonly a: number, b: number }, 'b'>
foo.a = 1 // expects error but none
declare const foo2: Omit<{ readonly a: number, b: number }, 'b'>
foo2.a = 1 // error as expectedExpected behavior:
Assignment to foo.a is an error.
Actual behavior:
No typing error reported.
Related Issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code