Posted in

TypeScript 瞄准真值和空值检查错误_AI阅读总结 — 包阅AI

包阅导读总结

1. 关键词:TypeScript 5.6、Truthy、Nullish、Bugs、Compiler

2. 总结:微软发布了 TypeScript 5.6 的测试版,该版本更新禁止了在某些语法上的空值和真值检查,编译器会在能确定检查结果时报错,称此举能捕获很多错误,部分表达式仍被允许。

3. 主要内容:

– TypeScript 5.6 发布

– 微软推出 TypeScript 5.6 测试版,紧跟上个月的 5.5 正式版。

– 禁止空值和真值检查

– 对从不为空值或真值变化的语法,禁止此类检查。

– 编译器在能确定检查结果时会报错,有望捕获很多错误。

– 允许的表达式

– 像 `true`、`false`、`0`、`1` 这些总是确定为真值或假值的表达式仍被允许。

– 获取方式

– 可通过 NuGet 或运行特定命令通过 NPM 获取。

思维导图:

文章地址:https://www.infoworld.com/article/3478113/typescript-5-6-takes-aim-at-truthy-and-nullish-bugs.html

文章来源:infoworld.com

作者:InfoWorld

发布时间:2024/7/26 21:18

语言:英文

总字数:373字

预计阅读时间:2分钟

评分:87分

标签:TypeScript,JavaScript,类型检查,空值检查,真值检查


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

Microsoft has released a beta of TypeScript 5.6, an update to the strongly typed JavaScript variant that disallows nullish and truthy checks on syntax that never varies on nullishness or truthiness.

The TypeScript 5.6 beta, which follows last month’s production release of TypeScript 5.5, was announced July 26. TypeScript 5.6 can be accessed through NuGet or through NPM by running the npm install -D typescript@beta command.

For disallowed nullish and truthy checks, the compiler now errors when it can syntactically determine that a truthy or nullish check will always evaluate in a specific way. Microsoft said “many, many bugs” could be caught this way. Some expressions still are allowed even if truthy or nullish. Specifically, true, false, 0, and 1 are all still allowed despite always being truthy or falsy.