ES5没有 Promise
例如,见 https:/stackoverflow.coma38424561. 然而,TypeScript库为ES5包含 Promise
定义。https:/github.commicrosoftTypeScriptblobmasterliblib.es5.d.ts#L1416。. 为什么?
该 lib.es5.d.ts
只声明 Promise
界面 (以及 PromiseLike
"thenable "接口和 PromiseConstructorLike
类型),这些都是非常有用的,而且不与任何特定的ES版本挂钩。
它可以 不 申报全球 var Promise
或本地人 Promise
构造函数及其静态方法。