GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
3.8 KiB

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