source: trip-planner-front/node_modules/tslib/README.md@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.8 KB
Line 
1# tslib
2
3This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions.
4
5This library is primarily used by the `--importHelpers` flag in TypeScript.
6When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file:
7
8```ts
9var __assign = (this && this.__assign) || Object.assign || function(t) {
10 for (var s, i = 1, n = arguments.length; i < n; i++) {
11 s = arguments[i];
12 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13 t[p] = s[p];
14 }
15 return t;
16};
17exports.x = {};
18exports.y = __assign({}, exports.x);
19
20```
21
22will instead be emitted as something like the following:
23
24```ts
25var tslib_1 = require("tslib");
26exports.x = {};
27exports.y = tslib_1.__assign({}, exports.x);
28```
29
30Because 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.
31For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`.
32
33# Installing
34
35For the latest stable version, run:
36
37## npm
38
39```sh
40# TypeScript 3.9.2 or later
41npm install tslib
42
43# TypeScript 3.8.4 or earlier
44npm install tslib@^1
45
46# TypeScript 2.3.2 or earlier
47npm install tslib@1.6.1
48```
49
50## yarn
51
52```sh
53# TypeScript 3.9.2 or later
54yarn add tslib
55
56# TypeScript 3.8.4 or earlier
57yarn add tslib@^1
58
59# TypeScript 2.3.2 or earlier
60yarn add tslib@1.6.1
61```
62
63## bower
64
65```sh
66# TypeScript 3.9.2 or later
67bower install tslib
68
69# TypeScript 3.8.4 or earlier
70bower install tslib@^1
71
72# TypeScript 2.3.2 or earlier
73bower install tslib@1.6.1
74```
75
76## JSPM
77
78```sh
79# TypeScript 3.9.2 or later
80jspm install tslib
81
82# TypeScript 3.8.4 or earlier
83jspm install tslib@^1
84
85# TypeScript 2.3.2 or earlier
86jspm install tslib@1.6.1
87```
88
89# Usage
90
91Set the `importHelpers` compiler option on the command line:
92
93```
94tsc --importHelpers file.ts
95```
96
97or in your tsconfig.json:
98
99```json
100{
101 "compilerOptions": {
102 "importHelpers": true
103 }
104}
105```
106
107#### For bower and JSPM users
108
109You will need to add a `paths` mapping for `tslib`, e.g. For Bower users:
110
111```json
112{
113 "compilerOptions": {
114 "module": "amd",
115 "importHelpers": true,
116 "baseUrl": "./",
117 "paths": {
118 "tslib" : ["bower_components/tslib/tslib.d.ts"]
119 }
120 }
121}
122```
123
124For JSPM users:
125
126```json
127{
128 "compilerOptions": {
129 "module": "system",
130 "importHelpers": true,
131 "baseUrl": "./",
132 "paths": {
133 "tslib" : ["jspm_packages/npm/tslib@2.x.y/tslib.d.ts"]
134 }
135 }
136}
137```
138
139## Deployment
140
141- Choose your new version number
142- Set it in `package.json` and `bower.json`
143- Create a tag: `git tag [version]`
144- Push the tag: `git push --tags`
145- Create a [release in GitHub](https://github.com/microsoft/tslib/releases)
146- Run the [publish to npm](https://github.com/microsoft/tslib/actions?query=workflow%3A%22Publish+to+NPM%22) workflow
147
148Done.
149
150# Contribute
151
152There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
153
154* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
155* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
156* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
157* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
158* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
159
160# Documentation
161
162* [Quick tutorial](http://www.typescriptlang.org/Tutorial)
163* [Programming handbook](http://www.typescriptlang.org/Handbook)
164* [Homepage](http://www.typescriptlang.org/)
Note: See TracBrowser for help on using the repository browser.