Closed
Description
Putting parenthesis around the "keyof T" syntax in an inline Mapped Type, strips out the field modifier (readonly).
Without parenthesis, or defining a template using the parenthesis, this doesn't happen.
TypeScript Version: 2.1.1
Code
interface MyType {
readonly a: number;
b: string;
}
type MyType2 = {
[P in keyof MyType]: MyType[P];
}
type MyType3 = {
[P in (keyof MyType)]: MyType[P];
}
type Test<T> = {
[P in (keyof T)]: T[P];
}
type MyType4 = Test<MyType>;
Expected behavior:
MyType2, MyType3, and MyType4 to all have the same signature.
Actual behavior:
MyType2 and MyType4 keeps the original MyType signature with modifiers.
MyType3 strips out the modifiers:
{
a: number;
b: string;
}