且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

TypeScript 中的破折号问号语法是什么?

更新时间:2022-04-18 05:41:28

你基本上是对的:它从 映射类型.它作为 控制映射类型修饰符的改进(有关您想要的文档,请参阅此链接).它与Required相同/code> 实用程序类型,但 Required用它实现(见此处为库定义),没有它就无法存在.

You are basically right: it removes the optional property modifier ? from a mapped type. It was introduced in TypeScript 2.8 as part of improvements to control over mapped type modifiers (see this link for the docs you want). It's not identical to the Required utility type, but Required is implemented with it (see library definition here) and could not exist without it.

令人遗憾的是,TypeScript 文档分散在手册、发行说明、常见问题解答、过时的规范和 GitHub 问题之间,没有明确的规范位置来查找任何特定内容.该语言的发展速度比文档还快.

It's a sad fact that TypeScript documentation is kind of spread out between the handbook, release notes, FAQ, outdated spec, and GitHub issues, without a clear canonical place to look for any particular thing. The language has been evolving more quickly than the documentation can keep up.

好的,希望有帮助;祝你好运!

Okay, hope that helps; good luck!