Installations
npm install tslib
Developer Guide
Typescript
No
Module System
CommonJS, ESM
Node Version
22.10.0
NPM Version
10.9.0
Releases
Contributors
Languages
TypeScript (74.77%)
JavaScript (25.14%)
HTML (0.1%)
Developer
Microsoft
Download Statistics
Total Downloads
35,047,242,065
Last Day
18,543,541
Last Week
111,848,464
Last Month
892,787,766
Last Year
12,296,903,255
GitHub Statistics
1,273 Stars
312 Commits
132 Forks
74 Watching
29 Branches
54 Contributors
Bundle Size
11.81 kB
Minified
3.98 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.8.1
Package Id
tslib@2.8.1
Unpacked Size
88.24 kB
Size
18.04 kB
File Count
14
NPM Version
10.9.0
Node Version
22.10.0
Publised On
31 Oct 2024
Total Downloads
Cumulative downloads
Total Downloads
35,047,242,065
Last day
-14.6%
18,543,541
Compared to previous day
Last week
-42.4%
111,848,464
Compared to previous week
Last month
-13.4%
892,787,766
Compared to previous month
Last year
10.2%
12,296,903,255
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
No dependencies detected.
tslib
This is a runtime library for TypeScript that contains all of the TypeScript helper functions.
This library is primarily used by the --importHelpers
flag in TypeScript.
When using --importHelpers
, a module that uses helper functions like __extends
and __assign
in the following emitted file:
1var __assign = (this && this.__assign) || Object.assign || function(t) { 2 for (var s, i = 1, n = arguments.length; i < n; i++) { 3 s = arguments[i]; 4 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 5 t[p] = s[p]; 6 } 7 return t; 8}; 9exports.x = {}; 10exports.y = __assign({}, exports.x); 11
will instead be emitted as something like the following:
1var tslib_1 = require("tslib"); 2exports.x = {}; 3exports.y = tslib_1.__assign({}, exports.x);
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.
For optimized bundles with TypeScript, you should absolutely consider using tslib
and --importHelpers
.
Installing
For the latest stable version, run:
npm
1# TypeScript 3.9.2 or later 2npm install tslib 3 4# TypeScript 3.8.4 or earlier 5npm install tslib@^1 6 7# TypeScript 2.3.2 or earlier 8npm install tslib@1.6.1
yarn
1# TypeScript 3.9.2 or later 2yarn add tslib 3 4# TypeScript 3.8.4 or earlier 5yarn add tslib@^1 6 7# TypeScript 2.3.2 or earlier 8yarn add tslib@1.6.1
bower
1# TypeScript 3.9.2 or later 2bower install tslib 3 4# TypeScript 3.8.4 or earlier 5bower install tslib@^1 6 7# TypeScript 2.3.2 or earlier 8bower install tslib@1.6.1
JSPM
1# TypeScript 3.9.2 or later 2jspm install tslib 3 4# TypeScript 3.8.4 or earlier 5jspm install tslib@^1 6 7# TypeScript 2.3.2 or earlier 8jspm install tslib@1.6.1
Usage
Set the importHelpers
compiler option on the command line:
tsc --importHelpers file.ts
or in your tsconfig.json:
1{ 2 "compilerOptions": { 3 "importHelpers": true 4 } 5}
For bower and JSPM users
You will need to add a paths
mapping for tslib
, e.g. For Bower users:
1{ 2 "compilerOptions": { 3 "module": "amd", 4 "importHelpers": true, 5 "baseUrl": "./", 6 "paths": { 7 "tslib" : ["bower_components/tslib/tslib.d.ts"] 8 } 9 } 10}
For JSPM users:
1{ 2 "compilerOptions": { 3 "module": "system", 4 "importHelpers": true, 5 "baseUrl": "./", 6 "paths": { 7 "tslib" : ["jspm_packages/npm/tslib@2.x.y/tslib.d.ts"] 8 } 9 } 10}
Deployment
- Choose your new version number
- Set it in
package.json
andbower.json
- Create a tag:
git tag [version]
- Push the tag:
git push --tags
- Create a release in GitHub
- Run the publish to npm workflow
Done.
Contribute
There are many ways to contribute to TypeScript.
- Submit bugs and help us verify fixes as they are checked in.
- Review the source code changes.
- Engage with other TypeScript users and developers on StackOverflow.
- Join the #typescript discussion on Twitter.
- Contribute bug fixes.
Documentation
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
0 existing vulnerabilities detected
Reason
project is fuzzed
Details
- Info: OSSFuzz integration found
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Info: FSF or OSI recognized license: BSD Zero Clause License: LICENSE.txt:0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:34
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:35
- Info: topLevel 'contents' permission set to 'read': .github/workflows/CI.yml:6
- Warn: no topLevel permission defined: .github/workflows/codeql.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/publish.yaml:9
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 9
Details
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yaml:20
- Info: 10 out of 10 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 24 commits out of 25 are checked with a SAST tool
Reason
9 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 8
Reason
Found 9/14 approved changesets -- score normalized to 6
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
- Warn: branch protection not enabled for branch '1.x'
Score
8
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More