polyfill
Code that adds a missing built-in feature to an older runtime, such as a Promise implementation for an old browser.
In more detail
A polyfill adds missing objects or methods at run time, while downleveling rewrites syntax at compile time. tsc does not add polyfills itself; it only rewrites syntax and assumes the lib objects exist.
Related terms
- downleveling — Rewriting modern JavaScript syntax into older, equivalent syntax so the code runs on an older target.
- target (compiler option) — The compiler option that chooses which ECMAScript edition the emitted JavaScript uses, such as ES2022.
- lib (compiler option) — The compiler option that lists which built-in type declarations are available, such as ES2022 features or browser DOM types.
Taught in
- The Compiler Pipeline: tsc, AST And Code Emission — Production TypeScript
- Modern Decorators: Stage 3 Standards And Class Metadata — Production TypeScript