tslib
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The tslib
is a runtime library for TypeScript that contains all the TypeScript helper functions. It is primarily used by the --importHelpers
flag in TypeScript. When used, modules that leverage helper functions like __extends
and __assign
will not repeat the declaration of these functions in the emitted file. Instead, these will be replaced with a call to the tslib
equivalents. This leads to smaller file sizes and less runtime overhead which makes for optimized bundles with TypeScript, offering an improved development experience.
To use tslib
in a TypeScript project, you first need to install the package using npm
or yarn
. Here is the installation code for different TypeScript versions:
# TypeScript 3.9.2 or later
npm install tslib
# TypeScript 3.8.4 or earlier
npm install tslib@^1
# TypeScript 2.3.2 or earlier
npm install tslib@1.6.1
You can also use yarn
for installation.
Once the tslib is installed, you need to enable the importHelpers
option in the TypeScript compiler. This can be done on the command line while running tsc:
tsc --importHelpers file.ts
Or it can be enabled in the compilerOptions attribute in tsconfig.json
:
{
"compilerOptions": {
"importHelpers": true
}
}
If you use Bower or JSPM, you'll also need to add a paths
mapping for tslib
in your tsconfig.json
.
The documentation for tslib
is located within the TypeScript's website. A quick tutorial and programming handbook are available to get acquainted with TypeScript, and by extension, its runtime library, tslib
. Additionally, for contributions, bug fixes and to monitor newly implemented fixes, you can visit TypeScript's Github page.