您现在的位置是:首页 > 文章详情

TypeScript 5.1 Beta 发布

日期:2023-04-19点击:189

TypeScript 5.1 发布了首个 Beta 测试版。

主要变化

旧代码

 function foo() { // no return } // x = undefined let x = foo();
 // fine - we inferred that 'f1' returns 'void' function f1() { // no returns } // fine - 'void' doesn't need a return statement function f2(): void { // no returns } // fine - 'any' doesn't need a return statement function f3(): any { // no returns } // error! // A function whose declared type is neither 'void' nor 'any' must return a value. function f4(): undefined { // no returns }

新代码

 // Works in TypeScript 5.1! function f4(): undefined { // no returns } // Works in TypeScript 5.1! takesFunction((): undefined => { // no returns });
 // Works in TypeScript 5.1! takesFunction(function f() { // ^ return type is undefined // no returns }); // Works in TypeScript 5.1! takesFunction(function f() { // ^ return type is undefined return; });

详情查看发布公告

原文链接:https://www.oschina.net/news/237457/typescript-5-1-beta
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章