Suggestion: DeepReadonly<T> type
**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx) **Code** It would be nice to have a shard, standard library type that allows to express deep readonly-ness (not really const, since methods are out of scope, but still...): ```ts interface Y { a: number; } interface X { y: Y; } let x: Readonly<X> = {y: {a: 1}}; x.y.a = 2; // Succeeds, which is expected, but it'd be nice to have a common way to express deep readonly type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]>; } let deepX: DeepReadonly<X> = {y: {a: 1}}; deepX.y.a = 2; // Fails as expected! ```
Posted by mprobst on Feb 7, 2017, 9:53 AM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Suggestion: DeepReadonly<T> type
**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx) **Code** It would be nice to have a shard, standard library type that allows to express deep readonly-ness (not really const, since methods are out of scope, but still...): ```ts interface Y { a: number; } interface X { y: Y; } let x: Readonly<X> = {y: {a: 1}}; x.y.a = 2; // Succeeds, which is expected, but it'd be nice to have a common way to express deep readonly type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]>; } let deepX: DeepReadonly<X> = {y: {a: 1}}; deepX.y.a = 2; // Fails as expected! ```
Comments (0)
No comments yet. Start the discussion.