Modules, Runtime & Tooling

Transpilation Targets & Polyfills

Transpilation rewrites syntax for older runtimes; polyfills provide missing runtime APIs. They solve different compatibility problems and are easy to confuse.
  • Transpilation rewrites syntax
  • Polyfills provide APIs
  • Type declarations are not runtime support
  • Targets should reflect supported environments
  • Polyfills affect global behavior
Compatibility tools
ToolSolvesDoes not solve
TranspilationUnsupported syntaxMissing built-in APIs
PolyfillMissing global/runtime APISyntax parsing errors
PonyfillLocal implementationGlobal compatibility expectations
Browserslist/targetEnvironment selectionActual user measurement
tsconfig libCompile-time API typesRuntime support
Syntax vs API
// Syntax can be transpiled:
const name = user?.profile?.name ?? "Unknown"

// Missing API needs runtime support or polyfill:
const copy = structuredClone(value)
The first is syntax; the second is a runtime API.
Sources
  • TypeScript Referencetarget and lib options
  • Vite DocumentationBuild target
  • MDN JavaScript Guide and ReferenceJavaScript reference and compatibility