Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
downlevel-dts
Advanced tools
The downlevel-dts npm package is used to downlevel TypeScript declaration files (.d.ts) to an older version of TypeScript. This is useful for library authors who want to support older versions of TypeScript without maintaining multiple versions of their codebase.
Downlevel TypeScript Declarations
This feature allows you to downlevel TypeScript declaration files to a specified TypeScript version. In this example, the input .d.ts file is downleveled to TypeScript version 3.7 and written to the output file.
const downlevelDts = require('downlevel-dts');
const fs = require('fs');
const inputFilePath = 'path/to/input.d.ts';
const outputFilePath = 'path/to/output.d.ts';
const inputDts = fs.readFileSync(inputFilePath, 'utf8');
const outputDts = downlevelDts(inputDts, '3.7');
fs.writeFileSync(outputFilePath, outputDts);
The TypeScript package itself can be used to generate declaration files, but it does not provide functionality to downlevel existing declaration files. It is more focused on compiling TypeScript code to JavaScript and generating .d.ts files from TypeScript source code.
API Extractor is a tool for managing and analyzing the public API surface of a TypeScript library. While it provides features for generating and validating .d.ts files, it does not specifically focus on downleveling them to older TypeScript versions.
dts-bundle-generator is a tool for generating a single .d.ts file from a TypeScript project. It focuses on bundling multiple declaration files into one, rather than downleveling existing declaration files.
$ npm install downlevel-dts
$ npx downlevel-dts . ts3.4
"typesVersions": {
"<=3.4.0-0": { "*": ["ts3.4/*"] }
}
$ cp tsconfig.json ts3.4/tsconfig.json
These instructions are modified and simplified from the Definitely Typed.
FAQs
Convert d.ts to be compatible with older typescript compilers
The npm package downlevel-dts receives a total of 156,096 weekly downloads. As such, downlevel-dts popularity was classified as popular.
We found that downlevel-dts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.