- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
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
interface MyType2 { readonly z1: number; z2: string; } interface MyType { readonly a: number; readonly b: MyType2; c: string; d: MyType2; } type Mock<T> { [P in keyofwithoutmodifiers T]: Mock<T[P]>; } type MyMockedType = 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
fahrradflucht, pyrocat101, ghetolay, monolithed and JetFault
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript