Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
@types/node
Advanced tools
The @types/node package contains TypeScript type definitions for Node.js. It provides TypeScript interfaces and types for Node.js modules, allowing developers to use TypeScript's static type checking with the Node.js runtime environment. This helps to catch errors at compile time and provides better editor support with features like auto-completion and inline documentation.
File System
Type definitions for the File System module allow developers to work with the file system using TypeScript, with methods for reading, writing, and manipulating the file system.
import * as fs from 'fs';
fs.readFile('/path/to/file', 'utf8', (err, data) => {
if (err) throw err;
console.log(data);
});
HTTP Server
Type definitions for the HTTP module enable developers to create HTTP servers and clients with TypeScript, handling requests and responses with proper type annotations.
import * as http from 'http';
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
server.listen(3000);
Events
Type definitions for the Events module provide types for event handling, allowing developers to work with event emitters and listeners in a type-safe manner.
import { EventEmitter } from 'events';
const eventEmitter = new EventEmitter();
eventEmitter.on('myEvent', (arg) => {
console.log(`Event fired with argument: ${arg}`);
});
eventEmitter.emit('myEvent', 'Hello Event!');
Streams
Type definitions for the Streams module help developers to work with Node.js streams, providing types for readable, writable, duplex, and transform streams.
import * as fs from 'fs';
import * as stream from 'stream';
const readStream = fs.createReadStream('/path/to/file');
const writeStream = fs.createWriteStream('/path/to/destination');
readStream.pipe(new stream.Transform({
transform(chunk, encoding, callback) {
// Transform the chunk to uppercase
callback(null, chunk.toString().toUpperCase());
}
})).pipe(writeStream);
Child Processes
Type definitions for the Child Processes module allow developers to spawn or execute new processes, providing types for handling the output and errors.
import { exec } from 'child_process';
exec('ls -lh /usr', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
The TypeScript package is the core compiler for TypeScript. It provides the language services and type checking for TypeScript code but does not include type definitions for Node.js, which @types/node provides.
ts-node is a TypeScript execution engine and REPL for Node.js. It allows you to run TypeScript files directly without pre-compiling them. It uses the TypeScript package for type checking but relies on @types/node for Node.js type definitions.
tslib is a runtime library for TypeScript that includes helper functions used by TypeScript emitted code. It does not provide type definitions but is often used alongside @types/node in TypeScript projects to reduce code duplication.
npm install --save @types/node
This package contains type definitions for Node.js (http://nodejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
Additional Details
These definitions were written by Microsoft TypeScript https://github.com/Microsoft, DefinitelyTyped https://github.com/DefinitelyTyped, Alberto Schiabel https://github.com/jkomyno, Alexander T. https://github.com/a-tarasyuk, Alvis HT Tang https://github.com/alvis, Andrew Makarov https://github.com/r3nya, Bruno Scheufler https://github.com/brunoscheufler, Chigozirim C. https://github.com/smac89, Christian Vaagland Tellnes https://github.com/tellnes, Deividas Bakanas https://github.com/DeividasBakanas, Eugene Y. Q. Shen https://github.com/eyqs, Flarna https://github.com/Flarna, Hannes Magnusson https://github.com/Hannes-Magnusson-CK, Hoàng Văn Khải https://github.com/KSXGitHub, Huw https://github.com/hoo29, Kelvin Jin https://github.com/kjin, Klaus Meinhardt https://github.com/ajafff, Lishude https://github.com/islishude, Mariusz Wiktorczyk https://github.com/mwiktorczyk, Matthieu Sieben https://github.com/matthieusieben, Mohsen Azimi https://github.com/mohsen1, Nicolas Even https://github.com/n-e, Nicolas Voigt https://github.com/octo-sniffle, Parambir Singh https://github.com/parambirs, Sebastian Silbermann https://github.com/eps1lon, Simon Schick https://github.com/SimonSchick, Thomas den Hollander https://github.com/ThomasdenH, Wilco Bakker https://github.com/WilcoBakker, wwwy3y3 https://github.com/wwwy3y3, Zane Hannan AU https://github.com/ZaneHannanAU, Jeremie Rodriguez https://github.com/jeremiergz, Samuel Ainsworth https://github.com/samuela.
FAQs
TypeScript definitions for node
We found that @types/node demonstrated a healthy version release cadence and project activity because the last version was released less than 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
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.