{"id":13512499,"url":"https://github.com/microsoft/tslib","last_synced_at":"2025-04-22T16:50:28.488Z","repository":{"id":30856778,"uuid":"34414315","full_name":"microsoft/tslib","owner":"microsoft","description":"Runtime library for TypeScript helpers.","archived":false,"fork":false,"pushed_at":"2024-10-31T22:40:56.000Z","size":482,"stargazers_count":1290,"open_issues_count":56,"forks_count":133,"subscribers_count":73,"default_branch":"main","last_synced_at":"2025-04-01T18:09:31.898Z","etag":null,"topics":["bundle","dependency","import","optimize","typescript","typescript-helpers"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-22T20:32:42.000Z","updated_at":"2025-03-25T21:08:36.000Z","dependencies_parsed_at":"2023-02-18T09:31:26.593Z","dependency_job_id":"4910b628-f5ea-4d76-85a9-ebdf3bb756b9","html_url":"https://github.com/microsoft/tslib","commit_stats":{"total_commits":236,"total_committers":47,"mean_commits":"5.0212765957446805","dds":0.8432203389830508,"last_synced_commit":"b0076c4070f7bae5730b49903529d8b27bc43e96"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ftslib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ftslib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ftslib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ftslib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/tslib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246995611,"owners_count":20866439,"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":["bundle","dependency","import","optimize","typescript","typescript-helpers"],"created_at":"2024-08-01T03:01:56.799Z","updated_at":"2025-04-08T19:08:24.010Z","avatar_url":"https://github.com/microsoft.png","language":"TypeScript","readme":"# tslib\r\n\r\nThis is a runtime library for [TypeScript](https://www.typescriptlang.org/) that contains all of the TypeScript helper functions.\r\n\r\nThis library is primarily used by the `--importHelpers` flag in TypeScript.\r\nWhen using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file:\r\n\r\n```ts\r\nvar __assign = (this \u0026\u0026 this.__assign) || Object.assign || function(t) {\r\n    for (var s, i = 1, n = arguments.length; i \u003c n; i++) {\r\n        s = arguments[i];\r\n        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n            t[p] = s[p];\r\n    }\r\n    return t;\r\n};\r\nexports.x = {};\r\nexports.y = __assign({}, exports.x);\r\n\r\n```\r\n\r\nwill instead be emitted as something like the following:\r\n\r\n```ts\r\nvar tslib_1 = require(\"tslib\");\r\nexports.x = {};\r\nexports.y = tslib_1.__assign({}, exports.x);\r\n```\r\n\r\nBecause this can avoid duplicate declarations of things like `__extends`, `__assign`, etc., this means delivering users smaller files on average, as well as less runtime overhead.\r\nFor optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`.\r\n\r\n# Installing\r\n\r\nFor the latest stable version, run:\r\n\r\n## npm\r\n\r\n```sh\r\n# TypeScript 3.9.2 or later\r\nnpm install tslib\r\n\r\n# TypeScript 3.8.4 or earlier\r\nnpm install tslib@^1\r\n\r\n# TypeScript 2.3.2 or earlier\r\nnpm install tslib@1.6.1\r\n```\r\n\r\n## yarn\r\n\r\n```sh\r\n# TypeScript 3.9.2 or later\r\nyarn add tslib\r\n\r\n# TypeScript 3.8.4 or earlier\r\nyarn add tslib@^1\r\n\r\n# TypeScript 2.3.2 or earlier\r\nyarn add tslib@1.6.1\r\n```\r\n\r\n## bower\r\n\r\n```sh\r\n# TypeScript 3.9.2 or later\r\nbower install tslib\r\n\r\n# TypeScript 3.8.4 or earlier\r\nbower install tslib@^1\r\n\r\n# TypeScript 2.3.2 or earlier\r\nbower install tslib@1.6.1\r\n```\r\n\r\n## JSPM\r\n\r\n```sh\r\n# TypeScript 3.9.2 or later\r\njspm install tslib\r\n\r\n# TypeScript 3.8.4 or earlier\r\njspm install tslib@^1\r\n\r\n# TypeScript 2.3.2 or earlier\r\njspm install tslib@1.6.1\r\n```\r\n\r\n# Usage\r\n\r\nSet the `importHelpers` compiler option on the command line:\r\n\r\n```\r\ntsc --importHelpers file.ts\r\n```\r\n\r\nor in your tsconfig.json:\r\n\r\n```json\r\n{\r\n    \"compilerOptions\": {\r\n        \"importHelpers\": true\r\n    }\r\n}\r\n```\r\n\r\n#### For bower and JSPM users\r\n\r\nYou will need to add a `paths` mapping for `tslib`, e.g. For Bower users:\r\n\r\n```json\r\n{\r\n    \"compilerOptions\": {\r\n        \"module\": \"amd\",\r\n        \"importHelpers\": true,\r\n        \"baseUrl\": \"./\",\r\n        \"paths\": {\r\n            \"tslib\" : [\"bower_components/tslib/tslib.d.ts\"]\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nFor JSPM users:\r\n\r\n```json\r\n{\r\n    \"compilerOptions\": {\r\n        \"module\": \"system\",\r\n        \"importHelpers\": true,\r\n        \"baseUrl\": \"./\",\r\n        \"paths\": {\r\n            \"tslib\" : [\"jspm_packages/npm/tslib@2.x.y/tslib.d.ts\"]\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n## Deployment\r\n\r\n- Choose your new version number\r\n- Set it in `package.json` and `bower.json`\r\n- Create a tag: `git tag [version]`\r\n- Push the tag: `git push --tags`\r\n- Create a [release in GitHub](https://github.com/microsoft/tslib/releases)\r\n- Run the [publish to npm](https://github.com/microsoft/tslib/actions?query=workflow%3A%22Publish+to+NPM%22) workflow\r\n\r\nDone.\r\n\r\n# Contribute\r\n\r\nThere are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.\r\n\r\n* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.\r\n* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).\r\n* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).\r\n* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.\r\n* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).\r\n\r\n# Documentation\r\n\r\n* [Quick tutorial](http://www.typescriptlang.org/Tutorial)\r\n* [Programming handbook](http://www.typescriptlang.org/Handbook)\r\n* [Homepage](http://www.typescriptlang.org/)\r\n","funding_links":[],"categories":["TypeScript","Tools"],"sub_categories":["WebTools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Ftslib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Ftslib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Ftslib/lists"}