15

技术周刊 2020-12-03:TypeScript 4.1 发布

 4 years ago
source link: https://zhuanlan.zhihu.com/p/330905895
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

技术周刊 2020-12-03:TypeScript 4.1 发布

前端开发话题下的优秀回答者

点评:理想状态下,我们直接使用 arr[-1] 会更加直观。但不幸的是,JS 的语言设计使其无法实现,因为[] 语法并不特定于数组和字符串,它也适用于所有对象。arr[-1] 实际上是返回该对象中名叫 -1 的属性值。

let arr = [1, 2, 3, 4]
arr.at(-2) // -> 3

// 此前我们通常使用
arr[arr.length - 2]

// String
'abc'.at('-1') // -> c

// TypedArray
let typedArray = new Int8Array(8)
typedArray[7] = 32
typedArray.at(-1) // -> 32
  • Electron 11.0.0 发布,实验性支持了 Apple M1 芯片(darwin arm64),Chromium 内核升级为 87。
  • Chrome Canary 的 DevTools 中实现了非常实用的复制 CSS 功能,通过右键菜单可以复制出格式化后的 CSS,还可以在全局设置中根据喜好配置缩进大小。
type World = "world";

type Greeting = `hello ${World}`;
// same as
//   type Greeting = "hello world";

type Color = "red" | "blue";
type Quantity = "one" | "two";

type SeussFish = `${Quantity | Color} fish`;
// same as
//   type SeussFish = "one fish" | "two fish"
//                  | "red fish" | "blue fish";
    • 映射类型中支持键重映射 (Key Remapping)
    • 递归条件类型额外支持 infer 关键字
    • 新增检查索引访问功能 noUncheckedIndexedAccess
    • 使用 paths 启用路径映射时可以不指定 baseUrl
    • checkJs 现在默认为 allowJs ,无需同时设置 checkJsallowJs
    • 支持了 React 17 的即将发布的功能 jsxjsxs 工厂函数
    • 编辑器支持 JSDoc 的 @see 标签

点评:Vuex 用户乐开了花。

优秀 Demo

v2-a6c01d3dafd27d67b923111996c7ec6b_b.jpg
v2-05ff1ce3b061e35da1bca68e2c832f24_b.jpg

本期编辑:@一丝;审阅:@承虎。


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK