3 This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions.
\r
5 This library is primarily used by the `--importHelpers` flag in TypeScript.
\r
6 When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file:
\r
9 var __assign = (this && this.__assign) || Object.assign || function(t) {
\r
10 for (var s, i = 1, n = arguments.length; i < n; i++) {
\r
12 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
\r
18 exports.y = __assign({}, exports.x);
\r
22 will instead be emitted as something like the following:
\r
25 var tslib_1 = require("tslib");
\r
27 exports.y = tslib_1.__assign({}, exports.x);
\r
30 Because 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
31 For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`.
\r
35 For the latest stable version, run:
\r
40 # TypeScript 3.9.2 or later
\r
43 # TypeScript 3.8.4 or earlier
\r
44 npm install tslib@^1
\r
46 # TypeScript 2.3.2 or earlier
\r
47 npm install tslib@1.6.1
\r
53 # TypeScript 3.9.2 or later
\r
56 # TypeScript 3.8.4 or earlier
\r
59 # TypeScript 2.3.2 or earlier
\r
60 yarn add tslib@1.6.1
\r
66 # TypeScript 3.9.2 or later
\r
69 # TypeScript 3.8.4 or earlier
\r
70 bower install tslib@^1
\r
72 # TypeScript 2.3.2 or earlier
\r
73 bower install tslib@1.6.1
\r
79 # TypeScript 3.9.2 or later
\r
82 # TypeScript 3.8.4 or earlier
\r
83 jspm install tslib@^1
\r
85 # TypeScript 2.3.2 or earlier
\r
86 jspm install tslib@1.6.1
\r
91 Set the `importHelpers` compiler option on the command line:
\r
94 tsc --importHelpers file.ts
\r
97 or in your tsconfig.json:
\r
101 "compilerOptions": {
\r
102 "importHelpers": true
\r
107 #### For bower and JSPM users
\r
109 You will need to add a `paths` mapping for `tslib`, e.g. For Bower users:
\r
113 "compilerOptions": {
\r
115 "importHelpers": true,
\r
118 "tslib" : ["bower_components/tslib/tslib.d.ts"]
\r
128 "compilerOptions": {
\r
129 "module": "system",
\r
130 "importHelpers": true,
\r
133 "tslib" : ["jspm_packages/npm/tslib@2.x.y/tslib.d.ts"]
\r
142 There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
\r
144 * [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
\r
145 * Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
\r
146 * Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
\r
147 * Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
\r
148 * [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
\r
152 * [Quick tutorial](http://www.typescriptlang.org/Tutorial)
\r
153 * [Programming handbook](http://www.typescriptlang.org/Handbook)
\r
154 * [Homepage](http://www.typescriptlang.org/)
\r