

技术周刊 2020-12-03:TypeScript 4.1 发布
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.

技术周刊 2020-12-03:TypeScript 4.1 发布
- Chrome V8 初步为可索引类 (Array, String, TypedArray) 实现了 .at() 方法,可以对它们进行负值索引,当前规范处于 Stage 3 阶段。
点评:理想状态下,我们直接使用
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,还可以在全局设置中根据喜好配置缩进大小。
- TypeScript 4.1 发布,带来了众多新特性:
- 引入了全新的「字符串模板类型」
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
,无需同时设置checkJs
和allowJs
- 支持了 React 17 的即将发布的功能
jsx
和jsxs
工厂函数 - 编辑器支持 JSDoc 的
@see
标签
点评:Vuex 用户乐开了花。
优秀 Demo


本期编辑:@一丝;审阅:@承虎。
Recommend
-
35
前端快爆 WebKit 已经实现了 ResizeObserver API,此前该 API 已被 Chrome 支持。通过 ResizeObserver 可以监听元素盒子尺寸的变化。? 点评:随着 Edge 迁移到 Chromium 内核,只剩 Fire
-
10
技术周刊 2020-11-23:Safari 14 首先默认支持 HTTP/3随着 macOS Big Sur 的推出,Safari 14 发布:DOM 层面...
-
38
技术周刊 2020-11-11:TPAC2020结束、TypeScript 4.1 RC发布
-
12
技术周刊 2020-10-27:Node.js 15 发布前端开发话题下的优秀回答者Node.js 15
-
10
技术周刊 2020-10-20:Chrome 启用细粒度缓存键npm
-
5
技术周刊 2020-09-27:Vue 3,抵达 ONE PIECE冯雨感谢你关注我,微信:feng1234yu经...
-
10
技术周刊 2020-08-25:TypeScript 4.0 正式发布,也许是学习TS最好的时候TypeScript 4.0 正式发布,包含如下新特性
-
14
技术周刊 2020-07-14:ES2020 正式发布ES2020 正式发布,此前进入 Stage 4 的提案均被纳入正式规范import()...
-
7
技术周刊 2020-06-29:Safari 14 Beta 版发布前端开发话题下的优秀回答者在北京时间 2020年6月23日召开的 WWDC 2020 会议上,
-
5
技术周刊 2021-11-30:React 18进入beta;TypeScript 4.5 正式发布;Chrome 96 发布Chrome 96 正式版发布浏览器
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK