Current TypeScript Version: 2.1.1
We have a syntax to add "readonly" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it.
This is useful for creating Mocked version of types for UTs, which have readonly fields in production.
This should work recursively.
Code
interfaceMyType2{readonlyz1: number;z2: string;}interfaceMyType{readonlya: number;readonlyb: MyType2;c: string;d: MyType2;}typeMock<T>{[PinkeyofwithoutmodifiersT]: Mock<T[P]>;}typeMyMockedType=Mock<MyType>;Expected behavior:
type MyMockedType to be
{
a: number;
b: { z1: number; z2: string};
c: string;
d: { z1: number; z2: string};}Actual behavior:
not possible right now
Current TypeScript Version: 2.1.1
We have a syntax to add "readonly" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it.
This is useful for creating Mocked version of types for UTs, which have readonly fields in production.
This should work recursively.
Code
Expected behavior:
type MyMockedType to be
Actual behavior:
not possible right now