{"id":24440623,"url":"https://github.com/ryanelian/ts-polyfill","last_synced_at":"2025-04-06T10:11:01.136Z","repository":{"id":55110962,"uuid":"130749322","full_name":"ryanelian/ts-polyfill","owner":"ryanelian","description":"Runtime polyfills for TypeScript libs, powered by core-js! :battery: :nut_and_bolt:","archived":false,"fork":false,"pushed_at":"2021-01-09T17:37:00.000Z","size":1592,"stargazers_count":143,"open_issues_count":7,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T09:07:48.153Z","etag":null,"topics":["es2015","es6","javascript","polyfill","promise","standard-library","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanelian.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-23T19:55:31.000Z","updated_at":"2025-03-16T01:04:57.000Z","dependencies_parsed_at":"2022-08-14T12:20:27.839Z","dependency_job_id":null,"html_url":"https://github.com/ryanelian/ts-polyfill","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanelian%2Fts-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanelian%2Fts-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanelian%2Fts-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanelian%2Fts-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanelian","download_url":"https://codeload.github.com/ryanelian/ts-polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464220,"owners_count":20942970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es2015","es6","javascript","polyfill","promise","standard-library","typescript"],"created_at":"2025-01-20T20:56:17.393Z","updated_at":"2025-04-06T10:11:01.113Z","avatar_url":"https://github.com/ryanelian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TS-Polyfill\n\n\u003e Runtime polyfills for TypeScript libs, powered by [core-js](https://github.com/zloirock/core-js)! :battery: :nut_and_bolt:\n\n[![npm](https://img.shields.io/npm/v/ts-polyfill.svg)](https://www.npmjs.com/package/ts-polyfill) [![GitHub Actions](https://github.com/ryanelian/ts-polyfill/workflows/Node%20CI/badge.svg)](https://github.com/ryanelian/ts-polyfill/actions)\n\n## Install\n\n`npm install ts-polyfill`\n\n## Getting Started\n\n- Modify your project `tsconfig.json` to add type definitions required.\n\n  - *(Obviously, you don't need EVERYTHING. Pick the ones you actually need to minimize bandwidth!)*\n\n  - In this example, we are targeting ES2015 so only ES2016 and above polyfills are needed:\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2015\",\n    \"lib\": [\n      \"DOM\",\n      \"DOM.Iterable\",\n      \"ES2015\",\n      \"ES2016.Array.Include\",\n      \"ES2017.Object\",\n      \"ES2017.String\",\n      \"ES2018.AsyncIterable\",\n      \"ES2018.Promise\",\n      \"ES2019.Array\",\n      \"ES2019.Object\",\n      \"ES2019.String\",\n      \"ES2019.Symbol\",\n      \"ES2020.Promise\",\n      \"ES2020.String\",\n      \"ES2020.Symbol.WellKnown\"\n    ]\n  }\n}\n```\n\n\u003e It is 2020 and you should be targeting ES2015. [Internet Explorer 11 and Windows 7 are no longer supported by Microsoft and no longer receive security patches](https://support.microsoft.com/en-us/help/17621/internet-explorer-downloads).\n\n- Then, in the entry point of your application, import the polyfills.\n\n  - The complete list of available polyfills (including ES2015 polyfills for poor souls targeting ES5) can be found here: https://github.com/ryanelian/ts-polyfill/tree/master/lib\n\n```ts\n// index.ts\nimport 'ts-polyfill/lib/es2016-array-include';\nimport 'ts-polyfill/lib/es2017-object';\nimport 'ts-polyfill/lib/es2017-string';\nimport 'ts-polyfill/lib/es2018-async-iterable';   // for-await-of\nimport 'ts-polyfill/lib/es2018-promise';\nimport 'ts-polyfill/lib/es2019-array';\nimport 'ts-polyfill/lib/es2019-object';\nimport 'ts-polyfill/lib/es2019-string';\nimport 'ts-polyfill/lib/es2019-symbol';\nimport 'ts-polyfill/lib/es2020-promise';\nimport 'ts-polyfill/lib/es2020-string';\nimport 'ts-polyfill/lib/es2020-symbol-wellknown';\n\nimport 'ts-polyfill/lib/es2020-global-this';      // globalThis (no tsconfig.json lib)\n```\n\n\u003e Shameless self-promotion: **use [instapack](https://github.com/ryanelian/instapack) for easy, rapid, and painless web app development using TypeScript!**\n\n## Alternative Techniques\n\n- Include everything implicitly: :ok_hand:\n\n  - EXCEPT these non-essential polyfills (for portability): `es2015-iterable, es2015-reflect, es2015-symbol, es2015-symbol-wellknown, es2017-typed-arrays, es2018-async-iterable, es2019-symbol, es2020-symbol-wellknown` \n\n```ts\nimport 'ts-polyfill';\n```\n\n- Include everything (also with exceptions listed above) using a pre-built script: download then include these as `\u003cscript\u003e` in your HTML (before your app script):\n\n  - [ts-polyfill.min.js](https://github.com/ryanelian/ts-polyfill/raw/master/dist/ts-polyfill.min.js) (51.85 KB, 18.37 KB gzip)\n\n  - [ts-polyfill.min.js.map](https://github.com/ryanelian/ts-polyfill/raw/master/dist/ts-polyfill.min.js.map) \n\n## FAQ\n\n### What's up with the semver?\n\nAbove version 0.0.4 (last known compatibility with TypeScript 2.8.3), we follow TypeScript version. Which means: ts-polyfill 2.9.0 is compatible with TypeScript 2.9.0 libs, and so on!\n\n**Release Cadence:** We will release new version if necessary whenever new TypeScript versions are published.\n\n### Which polyfill to include to use `downlevelIteration` when targeting ES5 in TypeScript?\n\n- `es2015-symbol`\n- `es2015-symbol-wellknown`\n- `es2015-iterable`\n\n### Why shouldn't I just use core-js directly?\n\n- We made extra efforts to guarantee (near) 100% coverage for polyfills of corresponding libs [by sweeping TypeScript libs API one-by-one](https://github.com/ryanelian/ts-polyfill/blob/master/src/es2015-core.ts).\n\n- We don't include lib polyfills which we consider to be 'unstable'\n\n  - **Example:** `esnext.feature` libs are probably unstable. We will wait for them to be marked as something like `es2018.feature` before attempting to polyfill them.\n\n- We will update the polyfills whenever [the official TypeScript libs](https://github.com/Microsoft/TypeScript/tree/master/lib) change. (It happens yo)\n\n- We will protect ts-polyfill consumers against breaking changes in core-js: our API will probably never change, but core-js API may change. (For example: core-js migration from version 2 to version 3)\n\n- We attempt to reduce total polyfill size by targeting ES5 instead of ES3.\n\n### What's the catch?\n\n- `ES2015.Core` [String.prototype.normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) polyfill is **GIGANTIC** (140 KB) and is not included.\n\n  - **If you REALLY need it,** use polyfill provided by [unorm](https://github.com/walling/unorm) library.\n\n- `ES2020.BigInt` lib is not included in this library. It can probably be polyfilled using a separate library which is Google's official BigInt implementation: https://github.com/GoogleChromeLabs/jsbi\n\n- ES2015 Reflect polyfills are best-effort. (15/20)\n\n- ES2015 Symbol and Well-Known Symbol polyfills are best-effort. (8/12 and 22/26)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanelian%2Fts-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanelian%2Fts-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanelian%2Fts-polyfill/lists"}