TypeScript 2.8 adds the ability for a mapped type to either add or remove a particular modifier. Specifically, a readonly or ? property modifier in a mapped type can now be prefixed with either + or - to indicate that the modifier should be added or removed.

type MutableRequired<T> = { -readonly [P in keyof T]-?: T[P] };  // Remove readonly and ?
type ReadonlyPartial<T> = { +readonly [P in keyof T]+?: T[P] };  // Add readonly and ?

Example:

type MutableRequired<T> = T extends object ? {-readonly [K in keyof T]: T[K]} : T;

interface Book {
readonly name: String;
} const newState: MutableRequired<Book> = {
name: 'st'
};

newState's anme is mutable and required.

最新文章

  1. [Hadoop in Action] 第1章 Hadoop简介
  2. 从github拉取项目到myeclipse本地
  3. 我的Windows naked apps
  4. Java多线程同步的方法
  5. js 日期插件 datepicker
  6. Java代码编写规范(不是标准规范,自行整理,无须纠结)
  7. linux tar命令 压缩、打包、解压 详解
  8. JAVA中生成、解析二维码图片的方法
  9. IDEA写scala简单操作
  10. mybatis之Mybatis_demo
  11. Taro 多端开发的正确姿势:打造三端统一的网易严选(小程序、H5、React Native)
  12. Nginx 如何减轻高流量下的压力
  13. VKD224B触摸芯片调试笔记
  14. Ubuntu系统安装
  15. ADB 命令介绍
  16. python的闭包函数
  17. W-D-S-UART编程
  18. HUE配置文件hue.ini 的hbase模块详解(图文详解)(分HA集群和非HA集群)
  19. 【Linux】VirtualBox安装ubuntu排错LowGraphic
  20. [转]CNN 中千奇百怪的卷积方式大汇总

热门文章

  1. mysql中数据表记录的增删查改(1)
  2. PAT(B) 1070 结绳(Java)
  3. (四)pdf的构成之文件体(树图)
  4. 在KubeSphere中部署Kubeapps
  5. axios ios 微信浏览器session问题
  6. Java JDK1.8源码学习之路 2 String
  7. Centos7 在线安装开发环境 jdk1.8+mysql+tomcat
  8. 封装的PKPM BimView的方法
  9. Selenium文件上传
  10. 如何在SAP UI5应用里添加使用摄像头拍照的功能