ES5 did not have Promise
, see for example https://stackoverflow.com/a/38424561. However, TypeScript library for ES5 contains Promise
definition: https://github.com/microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L1416. Why?
Asked
Active
Viewed 820 times
1

Alexey Berezkin
- 1,513
- 1
- 10
- 18
-
This seems like a better question to ask on https://github.com/microsoft/TypeScript/issues than Stack Overflow. – Heretic Monkey May 19 '20 at 18:15
-
They recommend asking questions on StackOverflow. – Alexey Berezkin May 19 '20 at 18:19
1 Answers
0
The lib.es5.d.ts
only declares the Promise
interface (and also the PromiseLike
"thenable" interface and the PromiseConstructorLike
type), which are pretty useful and not tied to any specific ES release.
It does not declare a global var Promise
or the native Promise
constructor and its static methods.

Bergi
- 630,263
- 148
- 957
- 1,375
-
Technically, if they are not tied to a ES release, they should be declared in a separate file, like `lib.promises.d.ts`, not a specific ES version release file like `lib.es5.d.ts`... – Heretic Monkey May 19 '20 at 20:07
-
@HereticMonkey That's true. No idea why it wasn't done like that, probably just nobody bothered to do it. Apparently `lib.es5.d.ts` serves as the sink for all "standard library" stuff (including utilities like `Partial` and so on), and is included in all other `lib.…` versions by reference. – Bergi May 19 '20 at 20:18