From fd899e3a79a34d6a97e21e58c3a7b76f1ceb1028 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:26:54 +0100 Subject: [PATCH 01/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74474=20Add?= =?UTF-8?q?=20types=20for=20find-pkg=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/find-pkg/.npmignore | 5 ++++ types/find-pkg/find-pkg-tests.ts | 35 +++++++++++++++++++++++ types/find-pkg/index.d.ts | 49 ++++++++++++++++++++++++++++++++ types/find-pkg/package.json | 21 ++++++++++++++ types/find-pkg/tsconfig.json | 19 +++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 types/find-pkg/.npmignore create mode 100644 types/find-pkg/find-pkg-tests.ts create mode 100644 types/find-pkg/index.d.ts create mode 100644 types/find-pkg/package.json create mode 100644 types/find-pkg/tsconfig.json diff --git a/types/find-pkg/.npmignore b/types/find-pkg/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/find-pkg/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/find-pkg/find-pkg-tests.ts b/types/find-pkg/find-pkg-tests.ts new file mode 100644 index 00000000000000..5edc77f2378182 --- /dev/null +++ b/types/find-pkg/find-pkg-tests.ts @@ -0,0 +1,35 @@ +import findPkg = require("find-pkg"); + +// Test promise usage +async function testPromise() { + const file: string | undefined = await findPkg("/some/path"); + if (file) { + const path: string = file; + } +} + +// Test callback usage +findPkg("/some/path", (err, file) => { + if (err) { + const error: Error = err; + return; + } + if (file) { + const path: string = file; + } +}); + +// Test sync usage +const syncFile: string | undefined = findPkg.sync("/some/path"); +if (syncFile) { + const path: string = syncFile; +} + +// Test with current directory +findPkg(".").then((file) => { + if (file !== undefined) { + const pkgPath: string = file; + } +}); + +const syncCurrent: string | undefined = findPkg.sync("."); diff --git a/types/find-pkg/index.d.ts b/types/find-pkg/index.d.ts new file mode 100644 index 00000000000000..a579f63aff0412 --- /dev/null +++ b/types/find-pkg/index.d.ts @@ -0,0 +1,49 @@ +/** + * Find the first directory with a package.json, recursing up from the given directory. + * + * @param cwd - The directory to start searching from + * @returns A promise that resolves to the path of the found package.json, or undefined if not found + * + * @example + * ```javascript + * const findPkg = require('find-pkg'); + * + * findPkg('a/b/c/some/path') + * .then(file => console.log(file)) + * .catch(console.error); + * ``` + */ +declare function findPkg(cwd: string): Promise; + +/** + * Find the first directory with a package.json, recursing up from the given directory. + * + * @param cwd - The directory to start searching from + * @param callback - Callback function called with (err, filepath) + * + * @example + * ```javascript + * findPkg('a/b/c/some/path', function(err, file) { + * if (err) throw err; + * console.log(file); + * }); + * ``` + */ +declare function findPkg(cwd: string, callback: (err: Error | null, file: string | undefined) => void): void; + +declare namespace findPkg { + /** + * Synchronously find the first directory with a package.json, recursing up from the given directory. + * + * @param cwd - The directory to start searching from + * @returns The path of the found package.json, or undefined if not found + * + * @example + * ```javascript + * const file = findPkg.sync('a/b/c/some/path'); + * ``` + */ + function sync(cwd: string): string | undefined; +} + +export = findPkg; diff --git a/types/find-pkg/package.json b/types/find-pkg/package.json new file mode 100644 index 00000000000000..b4d9ec591d08cf --- /dev/null +++ b/types/find-pkg/package.json @@ -0,0 +1,21 @@ +{ + "private": true, + "name": "@types/find-pkg", + "version": "2.0.9999", + "projects": [ + "https://github.com/jonschlinkert/find-pkg" + ], + "devDependencies": { + "@types/find-pkg": "workspace:." + }, + "owners": [ + { + "name": "Jon Schlinkert", + "githubUsername": "jonschlinkert" + }, + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/find-pkg/tsconfig.json b/types/find-pkg/tsconfig.json new file mode 100644 index 00000000000000..36876a8fecb9e0 --- /dev/null +++ b/types/find-pkg/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "find-pkg-tests.ts" + ] +} From 430a871bb5328d58de52d39889abf19bfa427571 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:27:15 +0100 Subject: [PATCH 02/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74473=20Add?= =?UTF-8?q?=20types=20for=20clone-stats=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/clone-stats/.npmignore | 5 +++++ types/clone-stats/clone-stats-tests.ts | 25 +++++++++++++++++++++++++ types/clone-stats/index.d.ts | 24 ++++++++++++++++++++++++ types/clone-stats/package.json | 20 ++++++++++++++++++++ types/clone-stats/tsconfig.json | 19 +++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 types/clone-stats/.npmignore create mode 100644 types/clone-stats/clone-stats-tests.ts create mode 100644 types/clone-stats/index.d.ts create mode 100644 types/clone-stats/package.json create mode 100644 types/clone-stats/tsconfig.json diff --git a/types/clone-stats/.npmignore b/types/clone-stats/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/clone-stats/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/clone-stats/clone-stats-tests.ts b/types/clone-stats/clone-stats-tests.ts new file mode 100644 index 00000000000000..56ea454571744f --- /dev/null +++ b/types/clone-stats/clone-stats-tests.ts @@ -0,0 +1,25 @@ +import cloneStats = require("clone-stats"); +import { Stats, statSync } from "fs"; + +// Get stats for a file (using package.json as example) +const stats: Stats = statSync("package.json"); + +// Clone the stats +const cloned: Stats = cloneStats(stats); + +// Verify cloned stats has all properties +const size: number = cloned.size; +const mode: number = cloned.mode; +const mtime: Date = cloned.mtime; +const atime: Date = cloned.atime; +const ctime: Date = cloned.ctime; +const birthtime: Date = cloned.birthtime; + +// Verify cloned stats has all methods +const isFile: boolean = cloned.isFile(); +const isDirectory: boolean = cloned.isDirectory(); +const isSymbolicLink: boolean = cloned.isSymbolicLink(); +const isBlockDevice: boolean = cloned.isBlockDevice(); +const isCharacterDevice: boolean = cloned.isCharacterDevice(); +const isFIFO: boolean = cloned.isFIFO(); +const isSocket: boolean = cloned.isSocket(); diff --git a/types/clone-stats/index.d.ts b/types/clone-stats/index.d.ts new file mode 100644 index 00000000000000..cd573d5e3349c0 --- /dev/null +++ b/types/clone-stats/index.d.ts @@ -0,0 +1,24 @@ +/// + +import { Stats } from "fs"; + +/** + * Safely clone a Node.js fs.Stats instance without losing class methods. + * + * @param stats - The fs.Stats instance to clone + * @returns A new Stats instance with the same properties + * + * @example + * ```javascript + * var fs = require('fs'); + * var cloneStats = require('clone-stats'); + * + * var stats = fs.statSync('file.txt'); + * var cloned = cloneStats(stats); + * + * cloned.isFile(); // still works! + * ``` + */ +declare function cloneStats(stats: Stats): Stats; + +export = cloneStats; diff --git a/types/clone-stats/package.json b/types/clone-stats/package.json new file mode 100644 index 00000000000000..4561e84942d3bf --- /dev/null +++ b/types/clone-stats/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/clone-stats", + "version": "1.0.9999", + "projects": [ + "https://github.com/hughsk/clone-stats" + ], + "dependencies": { + "@types/node": "*" + }, + "devDependencies": { + "@types/clone-stats": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/clone-stats/tsconfig.json b/types/clone-stats/tsconfig.json new file mode 100644 index 00000000000000..0c98e107ff051f --- /dev/null +++ b/types/clone-stats/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clone-stats-tests.ts" + ] +} From 068d579a0ec5c532cb90509230c44fb785d12308 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:27:53 +0100 Subject: [PATCH 03/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74471=20Add?= =?UTF-8?q?=20types=20for=20listenercount=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/listenercount/.npmignore | 5 ++++ types/listenercount/index.d.ts | 27 ++++++++++++++++++++++ types/listenercount/listenercount-tests.ts | 19 +++++++++++++++ types/listenercount/package.json | 20 ++++++++++++++++ types/listenercount/tsconfig.json | 19 +++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 types/listenercount/.npmignore create mode 100644 types/listenercount/index.d.ts create mode 100644 types/listenercount/listenercount-tests.ts create mode 100644 types/listenercount/package.json create mode 100644 types/listenercount/tsconfig.json diff --git a/types/listenercount/.npmignore b/types/listenercount/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/listenercount/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/listenercount/index.d.ts b/types/listenercount/index.d.ts new file mode 100644 index 00000000000000..a7f7b1df5c7dc7 --- /dev/null +++ b/types/listenercount/index.d.ts @@ -0,0 +1,27 @@ +/// + +import { EventEmitter } from "events"; + +/** + * Returns the number of listeners for a given event on an EventEmitter. + * Backwards-compatible polyfill for EventEmitter.listenerCount. + * + * @param emitter - The EventEmitter instance + * @param event - The event name + * @returns The number of listeners for the event + * + * @example + * ```javascript + * var listenerCount = require('listenercount'); + * var EventEmitter = require('events').EventEmitter; + * + * var ee = new EventEmitter(); + * ee.on('foo', function() {}); + * ee.on('foo', function() {}); + * + * listenerCount(ee, 'foo'); // => 2 + * ``` + */ +declare function listenerCount(emitter: EventEmitter, event: string | symbol): number; + +export = listenerCount; diff --git a/types/listenercount/listenercount-tests.ts b/types/listenercount/listenercount-tests.ts new file mode 100644 index 00000000000000..682a9f22b4c5e4 --- /dev/null +++ b/types/listenercount/listenercount-tests.ts @@ -0,0 +1,19 @@ +import listenerCount = require("listenercount"); +import { EventEmitter } from "events"; + +const ee = new EventEmitter(); + +// Add some listeners +ee.on("foo", () => {}); +ee.on("foo", () => {}); +ee.on("bar", () => {}); + +// Test listenerCount +const fooCount: number = listenerCount(ee, "foo"); +const barCount: number = listenerCount(ee, "bar"); +const bazCount: number = listenerCount(ee, "baz"); + +// Test with symbol event +const sym = Symbol("test"); +ee.on(sym, () => {}); +const symCount: number = listenerCount(ee, sym); diff --git a/types/listenercount/package.json b/types/listenercount/package.json new file mode 100644 index 00000000000000..a916ece3fbef77 --- /dev/null +++ b/types/listenercount/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/listenercount", + "version": "1.0.9999", + "projects": [ + "https://github.com/junosuarez/node-listenercount" + ], + "dependencies": { + "@types/node": "*" + }, + "devDependencies": { + "@types/listenercount": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/listenercount/tsconfig.json b/types/listenercount/tsconfig.json new file mode 100644 index 00000000000000..f553291250f6cc --- /dev/null +++ b/types/listenercount/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "listenercount-tests.ts" + ] +} From e32443a9f77db6a3ea2c4be838eb2fc69ccf388f Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:28:19 +0100 Subject: [PATCH 04/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74470=20Add?= =?UTF-8?q?=20types=20for=20rgbcolor=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/rgbcolor/.npmignore | 5 ++++ types/rgbcolor/index.d.ts | 51 ++++++++++++++++++++++++++++++++ types/rgbcolor/package.json | 17 +++++++++++ types/rgbcolor/rgbcolor-tests.ts | 30 +++++++++++++++++++ types/rgbcolor/tsconfig.json | 20 +++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 types/rgbcolor/.npmignore create mode 100644 types/rgbcolor/index.d.ts create mode 100644 types/rgbcolor/package.json create mode 100644 types/rgbcolor/rgbcolor-tests.ts create mode 100644 types/rgbcolor/tsconfig.json diff --git a/types/rgbcolor/.npmignore b/types/rgbcolor/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/rgbcolor/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/rgbcolor/index.d.ts b/types/rgbcolor/index.d.ts new file mode 100644 index 00000000000000..fa440e569d19f6 --- /dev/null +++ b/types/rgbcolor/index.d.ts @@ -0,0 +1,51 @@ +/** + * RGB color parser that handles various color formats. + * + * @example + * ```javascript + * var color = new RGBColor('red'); + * if (color.ok) { + * console.log(color.toHex()); // '#ff0000' + * } + * ``` + */ +declare class RGBColor { + /** + * Creates a new RGBColor instance by parsing a color string. + * @param colorString - A color string in various formats: + * - Named colors: 'red', 'blue', 'green', etc. + * - Hex: '#ff0000', 'ff0000', '#f00', 'f00' + * - RGB: 'rgb(255, 0, 0)' + * - RGBA: 'rgba(255, 0, 0, 0.5)' + */ + constructor(colorString: string); + + /** Whether the color was parsed successfully */ + ok: boolean; + + /** Red component (0-255) */ + r: number; + + /** Green component (0-255) */ + g: number; + + /** Blue component (0-255) */ + b: number; + + /** Alpha component (0-1) */ + alpha: number; + + /** Returns the color as an RGB string, e.g. 'rgb(255, 0, 0)' */ + toRGB(): string; + + /** Returns the color as an RGBA string, e.g. 'rgba(255, 0, 0, 0.5)' */ + toRGBA(): string; + + /** Returns the color as a hex string, e.g. '#ff0000' */ + toHex(): string; + + /** Returns an HTML element with color examples (browser only) */ + getHelpXML(): HTMLElement; +} + +export = RGBColor; diff --git a/types/rgbcolor/package.json b/types/rgbcolor/package.json new file mode 100644 index 00000000000000..fdc41f32365ae6 --- /dev/null +++ b/types/rgbcolor/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/rgbcolor", + "version": "1.0.9999", + "projects": [ + "https://github.com/yetzt/node-rgbcolor" + ], + "devDependencies": { + "@types/rgbcolor": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/rgbcolor/rgbcolor-tests.ts b/types/rgbcolor/rgbcolor-tests.ts new file mode 100644 index 00000000000000..217c128c1865cc --- /dev/null +++ b/types/rgbcolor/rgbcolor-tests.ts @@ -0,0 +1,30 @@ +import RGBColor = require("rgbcolor"); + +// Test with named color +const red = new RGBColor("red"); +const ok: boolean = red.ok; +const r: number = red.r; +const g: number = red.g; +const b: number = red.b; +const alpha: number = red.alpha; + +// Test conversion methods +const rgb: string = red.toRGB(); +const rgba: string = red.toRGBA(); +const hex: string = red.toHex(); + +// Test with hex color +const hexColor = new RGBColor("#ff0000"); +const hexColor2 = new RGBColor("ff0000"); +const hexColor3 = new RGBColor("#f00"); + +// Test with rgb() format +const rgbColor = new RGBColor("rgb(255, 0, 0)"); + +// Test with rgba() format +const rgbaColor = new RGBColor("rgba(255, 0, 0, 0.5)"); + +// Test checking if parse was successful +if (red.ok) { + const validHex: string = red.toHex(); +} diff --git a/types/rgbcolor/tsconfig.json b/types/rgbcolor/tsconfig.json new file mode 100644 index 00000000000000..b61a59b768d38c --- /dev/null +++ b/types/rgbcolor/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rgbcolor-tests.ts" + ] +} From 86bc78761aecbcb79669150b8b51a00bcb1f6662 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:29:26 +0100 Subject: [PATCH 05/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74461=20Add?= =?UTF-8?q?=20types=20for=20queue-tick=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/queue-tick/.npmignore | 5 +++++ types/queue-tick/index.d.ts | 20 ++++++++++++++++++++ types/queue-tick/package.json | 17 +++++++++++++++++ types/queue-tick/queue-tick-tests.ts | 17 +++++++++++++++++ types/queue-tick/tsconfig.json | 19 +++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 types/queue-tick/.npmignore create mode 100644 types/queue-tick/index.d.ts create mode 100644 types/queue-tick/package.json create mode 100644 types/queue-tick/queue-tick-tests.ts create mode 100644 types/queue-tick/tsconfig.json diff --git a/types/queue-tick/.npmignore b/types/queue-tick/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/queue-tick/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/queue-tick/index.d.ts b/types/queue-tick/index.d.ts new file mode 100644 index 00000000000000..8cfd53d2543cb1 --- /dev/null +++ b/types/queue-tick/index.d.ts @@ -0,0 +1,20 @@ +/** + * Schedules a callback to be invoked in the next tick. + * + * Uses `process.nextTick` when available (Node.js), falls back to + * `queueMicrotask` or `Promise.resolve().then()` in browsers. + * + * @param callback - The function to call in the next tick + * + * @example + * ```javascript + * const nextTick = require('queue-tick'); + * + * nextTick(() => { + * console.log('Called in next tick'); + * }); + * ``` + */ +declare function nextTick(callback: () => void): void; + +export = nextTick; diff --git a/types/queue-tick/package.json b/types/queue-tick/package.json new file mode 100644 index 00000000000000..f51d20c23a3c15 --- /dev/null +++ b/types/queue-tick/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/queue-tick", + "version": "1.0.9999", + "projects": [ + "https://github.com/mafintosh/queue-tick" + ], + "devDependencies": { + "@types/queue-tick": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/queue-tick/queue-tick-tests.ts b/types/queue-tick/queue-tick-tests.ts new file mode 100644 index 00000000000000..f588b41aa24851 --- /dev/null +++ b/types/queue-tick/queue-tick-tests.ts @@ -0,0 +1,17 @@ +import nextTick = require("queue-tick"); + +// Test basic usage +nextTick(() => { + // Called in next tick +}); + +// Test with inline function +nextTick(function callback() { + // do something +}); + +// Test that it accepts a void-returning function +const myCallback = (): void => { + // do something +}; +nextTick(myCallback); diff --git a/types/queue-tick/tsconfig.json b/types/queue-tick/tsconfig.json new file mode 100644 index 00000000000000..79a5ae44260115 --- /dev/null +++ b/types/queue-tick/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "queue-tick-tests.ts" + ] +} From 9b0bb37ef0aac6858c5c02e1c19ac2a6a6755b40 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:29:40 +0100 Subject: [PATCH 06/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74462=20Add?= =?UTF-8?q?=20types=20for=20parse-svg-path=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/parse-svg-path/.npmignore | 5 ++++ types/parse-svg-path/index.d.ts | 29 ++++++++++++++++++++ types/parse-svg-path/package.json | 17 ++++++++++++ types/parse-svg-path/parse-svg-path-tests.ts | 25 +++++++++++++++++ types/parse-svg-path/tsconfig.json | 19 +++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 types/parse-svg-path/.npmignore create mode 100644 types/parse-svg-path/index.d.ts create mode 100644 types/parse-svg-path/package.json create mode 100644 types/parse-svg-path/parse-svg-path-tests.ts create mode 100644 types/parse-svg-path/tsconfig.json diff --git a/types/parse-svg-path/.npmignore b/types/parse-svg-path/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/parse-svg-path/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/parse-svg-path/index.d.ts b/types/parse-svg-path/index.d.ts new file mode 100644 index 00000000000000..95412d39bf0552 --- /dev/null +++ b/types/parse-svg-path/index.d.ts @@ -0,0 +1,29 @@ +/** + * A parsed SVG path command. + * First element is the command letter (M, L, C, etc.), followed by numeric arguments. + */ +type PathCommand = [string, ...number[]]; + +/** + * Parse an SVG path data string into an array of commands. + * + * Each command is an array where the first element is the command letter + * and the remaining elements are the numeric arguments. + * + * @param path - SVG path data string (e.g., "M0 0 L10 10") + * @returns Array of parsed commands + * + * @example + * ```javascript + * const parse = require('parse-svg-path'); + * + * parse('M0 0 L10 10 Z'); + * // => [['M', 0, 0], ['L', 10, 10], ['Z']] + * + * parse('m10 10 h5 v5'); + * // => [['m', 10, 10], ['h', 5], ['v', 5]] + * ``` + */ +declare function parse(path: string): PathCommand[]; + +export = parse; diff --git a/types/parse-svg-path/package.json b/types/parse-svg-path/package.json new file mode 100644 index 00000000000000..64ce4ba4ea8221 --- /dev/null +++ b/types/parse-svg-path/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/parse-svg-path", + "version": "0.1.9999", + "projects": [ + "https://github.com/jkroso/parse-svg-path" + ], + "devDependencies": { + "@types/parse-svg-path": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/parse-svg-path/parse-svg-path-tests.ts b/types/parse-svg-path/parse-svg-path-tests.ts new file mode 100644 index 00000000000000..8b03878f75949f --- /dev/null +++ b/types/parse-svg-path/parse-svg-path-tests.ts @@ -0,0 +1,25 @@ +import parse = require("parse-svg-path"); + +// Test basic parsing +const commands = parse("M0 0 L10 10 Z"); + +// Each command is an array with command letter and args +const firstCommand: [string, ...number[]] = commands[0]; +const commandLetter: string = firstCommand[0]; + +// Test various SVG path commands +const moveAndLine = parse("M 10 20 L 30 40"); +const curves = parse("M0 0 C10 10 20 20 30 30"); +const arcs = parse("M0 0 A5 5 0 0 1 10 10"); +const relative = parse("m10 10 l5 5 h10 v10"); +const closePath = parse("M0 0 L10 0 L10 10 Z"); + +// Test that result is an array +const isArray: boolean = Array.isArray(commands); +const length: number = commands.length; + +// Test iteration +for (const cmd of commands) { + const letter: string = cmd[0]; + const args: number[] = cmd.slice(1) as number[]; +} diff --git a/types/parse-svg-path/tsconfig.json b/types/parse-svg-path/tsconfig.json new file mode 100644 index 00000000000000..def91f41db6268 --- /dev/null +++ b/types/parse-svg-path/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "parse-svg-path-tests.ts" + ] +} From 71104c1d84c7c7aa7d72411536d0a2c8af9473f5 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:29:53 +0100 Subject: [PATCH 07/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74463=20Add?= =?UTF-8?q?=20types=20for=20is-resolvable=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/is-resolvable/.npmignore | 5 ++++ types/is-resolvable/index.d.ts | 30 ++++++++++++++++++++++ types/is-resolvable/is-resolvable-tests.ts | 20 +++++++++++++++ types/is-resolvable/package.json | 17 ++++++++++++ types/is-resolvable/tsconfig.json | 19 ++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 types/is-resolvable/.npmignore create mode 100644 types/is-resolvable/index.d.ts create mode 100644 types/is-resolvable/is-resolvable-tests.ts create mode 100644 types/is-resolvable/package.json create mode 100644 types/is-resolvable/tsconfig.json diff --git a/types/is-resolvable/.npmignore b/types/is-resolvable/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/is-resolvable/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/is-resolvable/index.d.ts b/types/is-resolvable/index.d.ts new file mode 100644 index 00000000000000..32e5c756955556 --- /dev/null +++ b/types/is-resolvable/index.d.ts @@ -0,0 +1,30 @@ +/** + * Options for module resolution. + */ +interface ResolveOptions { + /** + * Paths to resolve module from. + */ + paths?: string[]; +} + +/** + * Check if a module ID is resolvable from the current working directory. + * + * @param moduleId - A valid Node.js module identifier (e.g., 'eslint', './index.js') + * @param options - Optional resolution options + * @returns true if the module can be resolved, false otherwise + * + * @example + * ```javascript + * const isResolvable = require('is-resolvable'); + * + * isResolvable('fs'); // => true (Node.js built-in) + * isResolvable('eslint'); // => true or false depending on installation + * isResolvable('./index.js'); // => true if file exists + * isResolvable('non-existent-module'); // => false + * ``` + */ +declare function isResolvable(moduleId: string, options?: ResolveOptions): boolean; + +export = isResolvable; diff --git a/types/is-resolvable/is-resolvable-tests.ts b/types/is-resolvable/is-resolvable-tests.ts new file mode 100644 index 00000000000000..4da91462e39e08 --- /dev/null +++ b/types/is-resolvable/is-resolvable-tests.ts @@ -0,0 +1,20 @@ +import isResolvable = require("is-resolvable"); + +// Test with module name +const builtIn: boolean = isResolvable("fs"); +const npmModule: boolean = isResolvable("typescript"); + +// Test with relative path +const relativePath: boolean = isResolvable("./index.js"); +const parentPath: boolean = isResolvable("../package.json"); + +// Test with options +const withPaths: boolean = isResolvable("some-module", { + paths: ["/custom/path", "/another/path"], +}); + +// Test with empty options +const emptyOptions: boolean = isResolvable("module", {}); + +// Result is always boolean +const result: boolean = isResolvable("anything"); diff --git a/types/is-resolvable/package.json b/types/is-resolvable/package.json new file mode 100644 index 00000000000000..584c688467c618 --- /dev/null +++ b/types/is-resolvable/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/is-resolvable", + "version": "1.1.9999", + "projects": [ + "https://github.com/shinnn/is-resolvable" + ], + "devDependencies": { + "@types/is-resolvable": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/is-resolvable/tsconfig.json b/types/is-resolvable/tsconfig.json new file mode 100644 index 00000000000000..698faa188a824f --- /dev/null +++ b/types/is-resolvable/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-resolvable-tests.ts" + ] +} From d4ea76ee879de8111872192f368a1eb08515ebe5 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:30:08 +0100 Subject: [PATCH 08/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74464=20Add?= =?UTF-8?q?=20types=20for=20amdefine=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/amdefine/.npmignore | 5 +++ types/amdefine/amdefine-tests.ts | 36 ++++++++++++++++++++++ types/amdefine/index.d.ts | 53 ++++++++++++++++++++++++++++++++ types/amdefine/package.json | 20 ++++++++++++ types/amdefine/tsconfig.json | 19 ++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 types/amdefine/.npmignore create mode 100644 types/amdefine/amdefine-tests.ts create mode 100644 types/amdefine/index.d.ts create mode 100644 types/amdefine/package.json create mode 100644 types/amdefine/tsconfig.json diff --git a/types/amdefine/.npmignore b/types/amdefine/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/amdefine/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/amdefine/amdefine-tests.ts b/types/amdefine/amdefine-tests.ts new file mode 100644 index 00000000000000..144512bd51d6ce --- /dev/null +++ b/types/amdefine/amdefine-tests.ts @@ -0,0 +1,36 @@ +/// + +import amdefine = require("amdefine"); + +// Create define function +const define = amdefine(module); + +// Define with dependencies and factory +define(["dep1", "dep2"], (dep1: any, dep2: any) => { + return { value: dep1 + dep2 }; +}); + +// Define with just factory +define(() => { + return { simple: true }; +}); + +// Define with id and dependencies +define("myModule", ["dep"], (dep: any) => { + return dep; +}); + +// Define with id, dependencies and value +define("myModule", ["dep"], { value: 42 }); + +// Define with just id and factory +define("simpleModule", () => ({ ok: true })); + +// Test define.amd property +const amd: object = define.amd; + +// Test define.require +const req: NodeRequire = define.require; + +// Create with explicit requireFn +const define2 = amdefine(module, require); diff --git a/types/amdefine/index.d.ts b/types/amdefine/index.d.ts new file mode 100644 index 00000000000000..c73a30be8bdfa4 --- /dev/null +++ b/types/amdefine/index.d.ts @@ -0,0 +1,53 @@ +/// + +/** + * AMD define function created by amdefine. + */ +interface Define { + /** + * Define a module with dependencies. + * @param id - Optional module ID + * @param dependencies - Array of dependency module IDs + * @param factory - Factory function or value + */ + (id: string, dependencies: string[], factory: (...modules: any[]) => any): void; + (id: string, dependencies: string[], factory: any): void; + (id: string, factory: (...modules: any[]) => any): void; + (id: string, factory: any): void; + (dependencies: string[], factory: (...modules: any[]) => any): void; + (dependencies: string[], factory: any): void; + (factory: (...modules: any[]) => any): void; + (factory: any): void; + + /** + * AMD define.amd property indicating AMD compatibility. + */ + amd: object; + + /** + * Require function for synchronous module loading. + */ + require: NodeRequire; +} + +/** + * Creates an AMD-style define function for use in Node.js modules. + * + * @param module - The Node.js module object for the current module + * @param requireFn - Optional require function (needed for Node < 0.5) + * @returns An AMD-compatible define function + * + * @example + * ```javascript + * if (typeof define !== 'function') { + * var define = require('amdefine')(module); + * } + * + * define(['dependency'], function(dep) { + * return { myModule: true }; + * }); + * ``` + */ +declare function amdefine(module: NodeModule, requireFn?: NodeRequire): Define; + +export = amdefine; diff --git a/types/amdefine/package.json b/types/amdefine/package.json new file mode 100644 index 00000000000000..143dd73ff427d3 --- /dev/null +++ b/types/amdefine/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/amdefine", + "version": "1.0.9999", + "projects": [ + "https://github.com/jrburke/amdefine" + ], + "dependencies": { + "@types/node": "*" + }, + "devDependencies": { + "@types/amdefine": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/amdefine/tsconfig.json b/types/amdefine/tsconfig.json new file mode 100644 index 00000000000000..ddc03dae016870 --- /dev/null +++ b/types/amdefine/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "amdefine-tests.ts" + ] +} From f0b8edd8b83325e6448cf6c2841bf494b3d6deae Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:30:27 +0100 Subject: [PATCH 09/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74465=20Add?= =?UTF-8?q?=20types=20for=20should-format=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/should-format/.npmignore | 5 ++ types/should-format/index.d.ts | 67 ++++++++++++++++++++++ types/should-format/package.json | 17 ++++++ types/should-format/should-format-tests.ts | 40 +++++++++++++ types/should-format/tsconfig.json | 19 ++++++ 5 files changed, 148 insertions(+) create mode 100644 types/should-format/.npmignore create mode 100644 types/should-format/index.d.ts create mode 100644 types/should-format/package.json create mode 100644 types/should-format/should-format-tests.ts create mode 100644 types/should-format/tsconfig.json diff --git a/types/should-format/.npmignore b/types/should-format/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/should-format/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/should-format/index.d.ts b/types/should-format/index.d.ts new file mode 100644 index 00000000000000..9d393bb5c77f82 --- /dev/null +++ b/types/should-format/index.d.ts @@ -0,0 +1,67 @@ +/** + * Options for the Formatter. + */ +interface FormatterOptions { + /** + * Custom function to get keys from an object. + */ + keysFunc?: (obj: object) => string[]; + + /** + * If false, uses Object.getOwnPropertyNames instead of Object.keys. + */ + keys?: boolean; + + /** + * Maximum line length before wrapping. Default: 60. + */ + maxLineLength?: number; + + /** + * Property separator. Default: ','. + */ + propSep?: string; + + /** + * If true, formats dates in UTC. + */ + isUTCdate?: boolean; +} + +/** + * Formatter class for converting values to string representations. + */ +declare class Formatter { + constructor(opts?: FormatterOptions); + + /** + * Format a value to a string representation. + * @param value - The value to format + * @returns Formatted string representation + */ + format(value: unknown): string; +} + +/** + * Default format function that creates a Formatter and formats the value. + * + * @param value - The value to format + * @param opts - Optional formatter options + * @returns Formatted string representation + * + * @example + * ```javascript + * const format = require('should-format'); + * + * format({ a: 1, b: 2 }); // => "{ a: 1, b: 2 }" + * format([1, 2, 3]); // => "[ 1, 2, 3 ]" + * format(null); // => "null" + * ``` + */ +declare function format(value: unknown, opts?: FormatterOptions): string; + +declare namespace format { + export { Formatter, FormatterOptions }; +} + +export = format; diff --git a/types/should-format/package.json b/types/should-format/package.json new file mode 100644 index 00000000000000..2a8239b6dda01c --- /dev/null +++ b/types/should-format/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/should-format", + "version": "3.0.9999", + "projects": [ + "https://github.com/shouldjs/format" + ], + "devDependencies": { + "@types/should-format": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/should-format/should-format-tests.ts b/types/should-format/should-format-tests.ts new file mode 100644 index 00000000000000..f33f8a89cdbb79 --- /dev/null +++ b/types/should-format/should-format-tests.ts @@ -0,0 +1,40 @@ +import format = require("should-format"); + +// Test default format function +const objStr: string = format({ a: 1, b: 2 }); +const arrStr: string = format([1, 2, 3]); +const nullStr: string = format(null); +const undefinedStr: string = format(undefined); +const numStr: string = format(42); +const boolStr: string = format(true); +const strStr: string = format("hello"); +const dateStr: string = format(new Date()); +const regexStr: string = format(/test/g); + +// Test with options +const withOptions: string = format({ a: 1 }, { + maxLineLength: 80, + propSep: ";", + isUTCdate: true, +}); + +// Test with keysFunc option +const withKeysFunc: string = format({ a: 1, b: 2 }, { + keysFunc: (obj) => Object.keys(obj).reverse(), +}); + +// Test with keys: false option +const withAllKeys: string = format({ a: 1 }, { + keys: false, +}); + +// Test Formatter class +const formatter = new format.Formatter(); +const formatted: string = formatter.format({ test: true }); + +// Test Formatter with options +const formatterWithOpts = new format.Formatter({ + maxLineLength: 100, + propSep: ",", +}); +const formatted2: string = formatterWithOpts.format([1, 2, 3]); diff --git a/types/should-format/tsconfig.json b/types/should-format/tsconfig.json new file mode 100644 index 00000000000000..dce39f9f138883 --- /dev/null +++ b/types/should-format/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "should-format-tests.ts" + ] +} From e122e251c9825a6e2b9b121c37ee3f6714cc406f Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:30:40 +0100 Subject: [PATCH 10/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74466=20Add?= =?UTF-8?q?=20types=20for=20webpack-log=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/webpack-log/.npmignore | 5 ++ types/webpack-log/index.d.ts | 77 ++++++++++++++++++++++++++ types/webpack-log/package.json | 17 ++++++ types/webpack-log/tsconfig.json | 19 +++++++ types/webpack-log/webpack-log-tests.ts | 34 ++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 types/webpack-log/.npmignore create mode 100644 types/webpack-log/index.d.ts create mode 100644 types/webpack-log/package.json create mode 100644 types/webpack-log/tsconfig.json create mode 100644 types/webpack-log/webpack-log-tests.ts diff --git a/types/webpack-log/.npmignore b/types/webpack-log/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/webpack-log/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/webpack-log/index.d.ts b/types/webpack-log/index.d.ts new file mode 100644 index 00000000000000..54e100a994d542 --- /dev/null +++ b/types/webpack-log/index.d.ts @@ -0,0 +1,77 @@ +/** + * Options for creating a webpack logger. + */ +interface WebpackLogOptions { + /** + * Log level. Default: 'info'. + */ + level?: "trace" | "debug" | "info" | "warn" | "error" | "silent"; + + /** + * Name of the logger. Default: ''. + */ + name?: string; + + /** + * Whether to include timestamp in output. Default: false. + */ + timestamp?: boolean; + + /** + * Whether to generate unique logger ID. Default: true. + */ + unique?: boolean; +} + +/** + * Logger instance returned by webpack-log. + */ +interface WebpackLogger { + /** + * Log at trace level. + */ + trace(...args: unknown[]): void; + + /** + * Log at debug level. + */ + debug(...args: unknown[]): void; + + /** + * Log at info level. + */ + info(...args: unknown[]): void; + + /** + * Log at warn level. + */ + warn(...args: unknown[]): void; + + /** + * Log at error level. + */ + error(...args: unknown[]): void; +} + +/** + * Creates a logger for the Webpack ecosystem. + * + * @param options - Logger configuration options + * @returns A logger instance with trace, debug, info, warn, and error methods + * + * @example + * ```javascript + * const getLogger = require('webpack-log'); + * + * const log = getLogger({ name: 'my-plugin' }); + * log.info('Starting plugin'); + * log.error('Something went wrong'); + * ``` + */ +declare function getLogger(options?: WebpackLogOptions): WebpackLogger; + +declare namespace getLogger { + export { WebpackLogger, WebpackLogOptions }; +} + +export = getLogger; diff --git a/types/webpack-log/package.json b/types/webpack-log/package.json new file mode 100644 index 00000000000000..acfe60bb1a54a0 --- /dev/null +++ b/types/webpack-log/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/webpack-log", + "version": "3.0.9999", + "projects": [ + "https://github.com/shellscape/webpack-log" + ], + "devDependencies": { + "@types/webpack-log": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/webpack-log/tsconfig.json b/types/webpack-log/tsconfig.json new file mode 100644 index 00000000000000..81b13ca8d9db4b --- /dev/null +++ b/types/webpack-log/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "webpack-log-tests.ts" + ] +} diff --git a/types/webpack-log/webpack-log-tests.ts b/types/webpack-log/webpack-log-tests.ts new file mode 100644 index 00000000000000..19f9af5b6ab3df --- /dev/null +++ b/types/webpack-log/webpack-log-tests.ts @@ -0,0 +1,34 @@ +import getLogger = require("webpack-log"); + +// Create logger with default options +const log = getLogger(); + +// Create logger with name +const namedLog = getLogger({ name: "my-webpack-plugin" }); + +// Create logger with all options +const fullLog = getLogger({ + name: "webpack-plugin", + level: "debug", + timestamp: true, + unique: false, +}); + +// Test log methods +log.trace("trace message"); +log.debug("debug message"); +log.info("info message"); +log.warn("warning message"); +log.error("error message"); + +// Test with multiple arguments +log.info("message", { data: 123 }); +log.error("error", new Error("test")); + +// Test log level options +getLogger({ level: "trace" }); +getLogger({ level: "debug" }); +getLogger({ level: "info" }); +getLogger({ level: "warn" }); +getLogger({ level: "error" }); +getLogger({ level: "silent" }); From d419e953e6379ebba98b77d6ba665f9e22e7efb1 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:30:56 +0100 Subject: [PATCH 11/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74467=20Add?= =?UTF-8?q?=20types=20for=20sort-keys-length=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/sort-keys-length/.npmignore | 5 +++ types/sort-keys-length/index.d.ts | 42 +++++++++++++++++++ types/sort-keys-length/package.json | 17 ++++++++ .../sort-keys-length-tests.ts | 30 +++++++++++++ types/sort-keys-length/tsconfig.json | 19 +++++++++ 5 files changed, 113 insertions(+) create mode 100644 types/sort-keys-length/.npmignore create mode 100644 types/sort-keys-length/index.d.ts create mode 100644 types/sort-keys-length/package.json create mode 100644 types/sort-keys-length/sort-keys-length-tests.ts create mode 100644 types/sort-keys-length/tsconfig.json diff --git a/types/sort-keys-length/.npmignore b/types/sort-keys-length/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/sort-keys-length/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/sort-keys-length/index.d.ts b/types/sort-keys-length/index.d.ts new file mode 100644 index 00000000000000..319457f90bf450 --- /dev/null +++ b/types/sort-keys-length/index.d.ts @@ -0,0 +1,42 @@ +/** + * Options for sorting object keys by length. + */ +interface SortKeysLengthOptions { + /** + * Recursively sort keys. + * @default false + */ + deep?: boolean; +} + +/** + * Sort object keys by length in ascending order (shortest first). + * + * @param object - Object to sort + * @param options - Sort options + * @returns A new object with keys sorted by length in ascending order + * + * @example + * ```javascript + * sortKeysLength.asc({ab: 'x', a: 'y', abc: 'z'}); + * //=> {a: 'y', ab: 'x', abc: 'z'} + * ``` + */ +declare function asc(object: T, options?: SortKeysLengthOptions): T; + +/** + * Sort object keys by length in descending order (longest first). + * + * @param object - Object to sort + * @param options - Sort options + * @returns A new object with keys sorted by length in descending order + * + * @example + * ```javascript + * sortKeysLength.desc({ab: 'x', a: 'y', abc: 'z'}); + * //=> {abc: 'z', ab: 'x', a: 'y'} + * ``` + */ +declare function desc(object: T, options?: SortKeysLengthOptions): T; + +export { asc, desc, SortKeysLengthOptions }; diff --git a/types/sort-keys-length/package.json b/types/sort-keys-length/package.json new file mode 100644 index 00000000000000..f3b52652968b14 --- /dev/null +++ b/types/sort-keys-length/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/sort-keys-length", + "version": "2.0.9999", + "projects": [ + "https://github.com/kevva/sort-keys-length" + ], + "devDependencies": { + "@types/sort-keys-length": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/sort-keys-length/sort-keys-length-tests.ts b/types/sort-keys-length/sort-keys-length-tests.ts new file mode 100644 index 00000000000000..b15603307012b1 --- /dev/null +++ b/types/sort-keys-length/sort-keys-length-tests.ts @@ -0,0 +1,30 @@ +import { asc, desc } from "sort-keys-length"; + +// Test ascending sort +const ascResult = asc({ ab: "x", a: "y", abc: "z" }); + +// Test descending sort +const descResult = desc({ ab: "x", a: "y", abc: "z" }); + +// Test with deep option +const deepAsc = asc({ ab: "x", a: "y" }, { deep: true }); +const deepDesc = desc({ ab: "x", a: "y" }, { deep: false }); + +// Test with nested objects +const nested = asc({ + longKey: { + short: 1, + longerKey: 2, + }, + a: "value", +}, { deep: true }); + +// Type preservation +interface MyObject { + foo: string; + barbaz: number; +} + +const typed: MyObject = { foo: "hello", barbaz: 42 }; +const sortedTyped: MyObject = asc(typed); +const sortedTypedDesc: MyObject = desc(typed); diff --git a/types/sort-keys-length/tsconfig.json b/types/sort-keys-length/tsconfig.json new file mode 100644 index 00000000000000..408a0777abf161 --- /dev/null +++ b/types/sort-keys-length/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sort-keys-length-tests.ts" + ] +} From 7ea74b667240b516d9fb88cb15448e93fdf17a14 Mon Sep 17 00:00:00 2001 From: Gaspard Beernaert Date: Thu, 5 Feb 2026 09:38:53 +0100 Subject: [PATCH 12/14] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74468=20Add?= =?UTF-8?q?=20types=20for=20html-parse-stringify=20by=20@gasp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/html-parse-stringify/.npmignore | 5 + .../html-parse-stringify-tests.ts | 52 +++++++++++ types/html-parse-stringify/index.d.ts | 92 +++++++++++++++++++ types/html-parse-stringify/package.json | 17 ++++ types/html-parse-stringify/tsconfig.json | 19 ++++ 5 files changed, 185 insertions(+) create mode 100644 types/html-parse-stringify/.npmignore create mode 100644 types/html-parse-stringify/html-parse-stringify-tests.ts create mode 100644 types/html-parse-stringify/index.d.ts create mode 100644 types/html-parse-stringify/package.json create mode 100644 types/html-parse-stringify/tsconfig.json diff --git a/types/html-parse-stringify/.npmignore b/types/html-parse-stringify/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/html-parse-stringify/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/html-parse-stringify/html-parse-stringify-tests.ts b/types/html-parse-stringify/html-parse-stringify-tests.ts new file mode 100644 index 00000000000000..1cd489bdab97b9 --- /dev/null +++ b/types/html-parse-stringify/html-parse-stringify-tests.ts @@ -0,0 +1,52 @@ +import { ASTNode, CommentNode, parse, ParseOptions, stringify, TagNode, TextNode } from "html-parse-stringify"; + +// Test parse function +const ast: ASTNode[] = parse("

hi

"); + +// Test parse with options +const astWithOpts: ASTNode[] = parse("
", { + components: { + "my-component": true, + }, +}); + +// Test stringify function +const htmlString: string = stringify(ast); + +// Test roundtrip +const ast2: ASTNode[] = parse("

hello

"); +const html2: string = stringify(ast2); + +// Test node type narrowing +for (const node of ast) { + if (node.type === "tag") { + const tagNode: TagNode = node; + const name: string = tagNode.name; + const attrs: { [key: string]: string } = tagNode.attrs; + const isVoid: boolean = tagNode.voidElement; + const children: ASTNode[] = tagNode.children; + } else if (node.type === "text") { + const textNode: TextNode = node; + const content: string = textNode.content; + } else if (node.type === "comment") { + const commentNode: CommentNode = node; + const comment: string = commentNode.comment; + } else if (node.type === "component") { + const name: string = node.name; + const attrs: { [key: string]: string } = node.attrs; + } +} + +// Test with complex HTML +const complexAst = parse(` +
+

Title

+ +

Some bold text

+ +
+`); + +// Test roundtrip +const original = "

test

"; +const roundtrip: string = stringify(parse(original)); diff --git a/types/html-parse-stringify/index.d.ts b/types/html-parse-stringify/index.d.ts new file mode 100644 index 00000000000000..d014fa16b3bf13 --- /dev/null +++ b/types/html-parse-stringify/index.d.ts @@ -0,0 +1,92 @@ +/** + * Attributes object for a tag node. + */ +export interface Attributes { + [key: string]: string; +} + +/** + * A tag node in the AST. + */ +export interface TagNode { + type: "tag"; + name: string; + attrs: Attributes; + voidElement: boolean; + children: ASTNode[]; +} + +/** + * A text node in the AST. + */ +export interface TextNode { + type: "text"; + content: string; +} + +/** + * A comment node in the AST. + */ +export interface CommentNode { + type: "comment"; + comment: string; +} + +/** + * A component node in the AST. + * Similar to tag but children are ignored during parsing. + */ +export interface ComponentNode { + type: "component"; + name: string; + attrs: Attributes; + voidElement: boolean; + children: ASTNode[]; +} + +/** + * Any AST node type. + */ +export type ASTNode = TagNode | TextNode | CommentNode | ComponentNode; + +/** + * Options for parsing HTML. + */ +export interface ParseOptions { + /** + * Object of registered component names whose children will be ignored + * when generating the AST. + */ + components?: { + [componentName: string]: boolean | object; + }; +} + +/** + * Parses a string of HTML into an AST. + * + * @param html - The HTML string to parse + * @param options - Parse options + * @returns An array of AST nodes + * + * @example + * ```javascript + * var HTML = require('html-parse-stringify'); + * var ast = HTML.parse('

hi

'); + * ``` + */ +export function parse(html: string, options?: ParseOptions): ASTNode[]; + +/** + * Stringifies an AST back to HTML. + * + * @param ast - The AST to stringify + * @returns The HTML string + * + * @example + * ```javascript + * var HTML = require('html-parse-stringify'); + * var html = HTML.stringify(ast); + * ``` + */ +export function stringify(ast: ASTNode[]): string; diff --git a/types/html-parse-stringify/package.json b/types/html-parse-stringify/package.json new file mode 100644 index 00000000000000..88c323a42a6f03 --- /dev/null +++ b/types/html-parse-stringify/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/html-parse-stringify", + "version": "3.0.9999", + "projects": [ + "https://github.com/henrikjoreteg/html-parse-stringify" + ], + "devDependencies": { + "@types/html-parse-stringify": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/html-parse-stringify/tsconfig.json b/types/html-parse-stringify/tsconfig.json new file mode 100644 index 00000000000000..8865bb4dfb8f5f --- /dev/null +++ b/types/html-parse-stringify/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "html-parse-stringify-tests.ts" + ] +} From 7e7c5cac08d4c9a13f29c8fdabe6bb66ba79f230 Mon Sep 17 00:00:00 2001 From: Andrew Aquino Date: Thu, 5 Feb 2026 01:43:08 -0800 Subject: [PATCH 13/14] [react] wrap JSDoc URLs in @link tags (#74481) --- types/react/experimental.d.ts | 4 +- types/react/index.d.ts | 4 +- types/react/ts5.0/experimental.d.ts | 4 +- types/react/ts5.0/index.d.ts | 4 +- types/react/v15/index.d.ts | 4 +- types/react/v16/index.d.ts | 68 ++++++++++++------------- types/react/v17/index.d.ts | 68 ++++++++++++------------- types/react/v18/canary.d.ts | 2 +- types/react/v18/experimental.d.ts | 6 +-- types/react/v18/index.d.ts | 2 +- types/react/v18/ts5.0/canary.d.ts | 2 +- types/react/v18/ts5.0/experimental.d.ts | 6 +-- types/react/v18/ts5.0/index.d.ts | 2 +- 13 files changed, 88 insertions(+), 88 deletions(-) diff --git a/types/react/experimental.d.ts b/types/react/experimental.d.ts index 49ff8620cd9b8c..5c448d90937f1e 100644 --- a/types/react/experimental.d.ts +++ b/types/react/experimental.d.ts @@ -106,8 +106,8 @@ declare module "." { * However, if you wrap these items in a `SuspenseList`, React will not show an item in the list * until previous items have been displayed (this behavior is adjustable). * - * @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist - * @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist + * @see {@link https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist} + * @see {@link https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist} */ export const unstable_SuspenseList: ExoticComponent; diff --git a/types/react/index.d.ts b/types/react/index.d.ts index de2143c01ea47e..f16a2622acfb03 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1885,7 +1885,7 @@ declare namespace React { * * @param callback A synchronous, void callback that will execute as a single, complete React commit. * - * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks + * @see {@link https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks} */ // NOTES // - the order of these signatures matters - typescript will check the signatures in source order. @@ -2841,7 +2841,7 @@ declare namespace React { // Living Standard /** - * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert} */ inert?: boolean | undefined; /** diff --git a/types/react/ts5.0/experimental.d.ts b/types/react/ts5.0/experimental.d.ts index 49ff8620cd9b8c..5c448d90937f1e 100644 --- a/types/react/ts5.0/experimental.d.ts +++ b/types/react/ts5.0/experimental.d.ts @@ -106,8 +106,8 @@ declare module "." { * However, if you wrap these items in a `SuspenseList`, React will not show an item in the list * until previous items have been displayed (this behavior is adjustable). * - * @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist - * @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist + * @see {@link https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist} + * @see {@link https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist} */ export const unstable_SuspenseList: ExoticComponent; diff --git a/types/react/ts5.0/index.d.ts b/types/react/ts5.0/index.d.ts index a0be2172632c55..a57ee49ea69509 100644 --- a/types/react/ts5.0/index.d.ts +++ b/types/react/ts5.0/index.d.ts @@ -1884,7 +1884,7 @@ declare namespace React { * * @param callback A synchronous, void callback that will execute as a single, complete React commit. * - * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks + * @see {@link https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks} */ // NOTES // - the order of these signatures matters - typescript will check the signatures in source order. @@ -2840,7 +2840,7 @@ declare namespace React { // Living Standard /** - * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert} */ inert?: boolean | undefined; /** diff --git a/types/react/v15/index.d.ts b/types/react/v15/index.d.ts index 0c3382590996a8..4887eba90db52c 100644 --- a/types/react/v15/index.d.ts +++ b/types/react/v15/index.d.ts @@ -2721,12 +2721,12 @@ declare namespace React { // Living Standard /** * Hints at the type of data that might be entered by the user while editing the element or its contents - * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute + * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute} */ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined; /** * Specify that a standard HTML element should behave like a defined custom built-in element - * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is + * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is} */ is?: string | undefined; /** diff --git a/types/react/v16/index.d.ts b/types/react/v16/index.d.ts index ac5eadc34935eb..4ef639a161887d 100644 --- a/types/react/v16/index.d.ts +++ b/types/react/v16/index.d.ts @@ -457,7 +457,7 @@ declare namespace React { * } * ``` * - * @see https://react.dev/reference/react/Component#static-contexttype + * @see {@link https://react.dev/reference/react/Component#static-contexttype} */ static contextType?: Context | undefined; @@ -474,7 +474,7 @@ declare namespace React { * declare context: React.ContextType * ``` * - * @see https://react.dev/reference/react/Component#context + * @see {@link https://react.dev/reference/react/Component#context} */ // TODO (TypeScript 3.0): unknown context: any; @@ -482,7 +482,7 @@ declare namespace React { constructor(props: Readonly

| P); /** * @deprecated - * @see https://legacy.reactjs.org/docs/legacy-context.html + * @see {@link https://legacy.reactjs.org/docs/legacy-context.html} */ constructor(props: P, context: any); @@ -698,8 +698,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17 - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ componentWillMount?(): void; /** @@ -712,8 +712,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use componentDidMount or the constructor instead - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ UNSAFE_componentWillMount?(): void; /** @@ -727,8 +727,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17 - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; /** @@ -744,8 +744,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use static getDerivedStateFromProps instead - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ UNSAFE_componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; /** @@ -757,8 +757,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17 - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; /** @@ -772,8 +772,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use getSnapshotBeforeUpdate instead - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ UNSAFE_componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; } @@ -915,14 +915,14 @@ declare namespace React { * context value, as given by the nearest context provider for the given context. * * @version 16.8.0 - * @see https://react.dev/reference/react/useContext + * @see {@link https://react.dev/reference/react/useContext} */ function useContext(context: Context /*, (not public API) observedBits?: number|boolean */): T; /** * Returns a stateful value, and a function to update it. * * @version 16.8.0 - * @see https://react.dev/reference/react/useState + * @see {@link https://react.dev/reference/react/useState} */ function useState(initialState: S | (() => S)): [S, Dispatch>]; // convenience overload when first argument is omitted @@ -930,7 +930,7 @@ declare namespace React { * Returns a stateful value, and a function to update it. * * @version 16.8.0 - * @see https://react.dev/reference/react/useState + * @see {@link https://react.dev/reference/react/useState} */ function useState(): [S | undefined, Dispatch>]; /** @@ -941,7 +941,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload where dispatch could accept 0 arguments. function useReducer, I>( @@ -957,7 +957,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload where dispatch could accept 0 arguments. function useReducer>( @@ -973,7 +973,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload where "I" may be a subset of ReducerState; used to provide autocompletion. // If "I" matches ReducerState exactly then the last overload will allow initializer to be omitted. @@ -991,7 +991,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload for free "I"; all goes as long as initializer converts it into "ReducerState". function useReducer, I>( @@ -1007,7 +1007,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary. @@ -1032,7 +1032,7 @@ declare namespace React { * value around similar to how you’d use instance fields in classes. * * @version 16.8.0 - * @see https://react.dev/reference/react/useRef + * @see {@link https://react.dev/reference/react/useRef} */ function useRef(initialValue: T): MutableRefObject; // convenience overload for refs given as a ref prop as they typically start with a null value @@ -1047,7 +1047,7 @@ declare namespace React { * of the generic argument. * * @version 16.8.0 - * @see https://react.dev/reference/react/useRef + * @see {@link https://react.dev/reference/react/useRef} */ function useRef(initialValue: T | null): RefObject; // convenience overload for potentially undefined initialValue / call with 0 arguments @@ -1060,7 +1060,7 @@ declare namespace React { * value around similar to how you’d use instance fields in classes. * * @version 16.8.0 - * @see https://react.dev/reference/react/useRef + * @see {@link https://react.dev/reference/react/useRef} */ function useRef(): MutableRefObject; /** @@ -1074,7 +1074,7 @@ declare namespace React { * `componentDidMount` and `componentDidUpdate`. * * @version 16.8.0 - * @see https://react.dev/reference/react/useLayoutEffect + * @see {@link https://react.dev/reference/react/useLayoutEffect} */ function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void; /** @@ -1084,7 +1084,7 @@ declare namespace React { * @param deps If present, effect will only activate if the values in the list change. * * @version 16.8.0 - * @see https://react.dev/reference/react/useEffect + * @see {@link https://react.dev/reference/react/useEffect} */ function useEffect(effect: EffectCallback, deps?: DependencyList): void; // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref @@ -1095,7 +1095,7 @@ declare namespace React { * `useImperativeHandle` should be used with `React.forwardRef`. * * @version 16.8.0 - * @see https://react.dev/reference/react/useImperativeHandle + * @see {@link https://react.dev/reference/react/useImperativeHandle} */ function useImperativeHandle(ref: Ref | undefined, init: () => R, deps?: DependencyList): void; // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key @@ -1105,7 +1105,7 @@ declare namespace React { * has changed. * * @version 16.8.0 - * @see https://react.dev/reference/react/useCallback + * @see {@link https://react.dev/reference/react/useCallback} */ // TODO (TypeScript 3.0): unknown> function useCallback any>(callback: T, deps: DependencyList): T; @@ -1113,7 +1113,7 @@ declare namespace React { * `useMemo` will only recompute the memoized value when one of the `deps` has changed. * * @version 16.8.0 - * @see https://react.dev/reference/react/useMemo + * @see {@link https://react.dev/reference/react/useMemo} */ // allow undefined, but don't make it optional as that is very likely a mistake function useMemo(factory: () => T, deps: DependencyList | undefined): T; @@ -1124,7 +1124,7 @@ declare namespace React { * It’s most valuable for custom hooks that are part of shared libraries. * * @version 16.8.0 - * @see https://react.dev/reference/react/useDebugValue + * @see {@link https://react.dev/reference/react/useDebugValue} */ // the name of the custom hook is itself derived from the function name at runtime: // it's just the function name without the "use" prefix. @@ -1921,12 +1921,12 @@ declare namespace React { // Living Standard /** * Hints at the type of data that might be entered by the user while editing the element or its contents - * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute + * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute} */ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined; /** * Specify that a standard HTML element should behave like a defined custom built-in element - * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is + * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is} */ is?: string | undefined; /** diff --git a/types/react/v17/index.d.ts b/types/react/v17/index.d.ts index 2673aaf43b3678..6fc8e255069f37 100644 --- a/types/react/v17/index.d.ts +++ b/types/react/v17/index.d.ts @@ -457,7 +457,7 @@ declare namespace React { * } * ``` * - * @see https://react.dev/reference/react/Component#static-contexttype + * @see {@link https://react.dev/reference/react/Component#static-contexttype} */ static contextType?: Context | undefined; @@ -474,7 +474,7 @@ declare namespace React { * declare context: React.ContextType * ``` * - * @see https://react.dev/reference/react/Component#context + * @see {@link https://react.dev/reference/react/Component#context} */ // TODO (TypeScript 3.0): unknown context: any; @@ -482,7 +482,7 @@ declare namespace React { constructor(props: Readonly

| P); /** * @deprecated - * @see https://legacy.reactjs.org/docs/legacy-context.html + * @see {@link https://legacy.reactjs.org/docs/legacy-context.html} */ constructor(props: P, context: any); @@ -698,8 +698,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17 - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ componentWillMount?(): void; /** @@ -712,8 +712,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use componentDidMount or the constructor instead - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ UNSAFE_componentWillMount?(): void; /** @@ -727,8 +727,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17 - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; /** @@ -744,8 +744,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use static getDerivedStateFromProps instead - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ UNSAFE_componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; /** @@ -757,8 +757,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17 - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; /** @@ -772,8 +772,8 @@ declare namespace React { * prevents this from being invoked. * * @deprecated 16.3, use getSnapshotBeforeUpdate instead - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update - * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update} + * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path} */ UNSAFE_componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; } @@ -915,14 +915,14 @@ declare namespace React { * context value, as given by the nearest context provider for the given context. * * @version 16.8.0 - * @see https://react.dev/reference/react/useContext + * @see {@link https://react.dev/reference/react/useContext} */ function useContext(context: Context /*, (not public API) observedBits?: number|boolean */): T; /** * Returns a stateful value, and a function to update it. * * @version 16.8.0 - * @see https://react.dev/reference/react/useState + * @see {@link https://react.dev/reference/react/useState} */ function useState(initialState: S | (() => S)): [S, Dispatch>]; // convenience overload when first argument is omitted @@ -930,7 +930,7 @@ declare namespace React { * Returns a stateful value, and a function to update it. * * @version 16.8.0 - * @see https://react.dev/reference/react/useState + * @see {@link https://react.dev/reference/react/useState} */ function useState(): [S | undefined, Dispatch>]; /** @@ -941,7 +941,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload where dispatch could accept 0 arguments. function useReducer, I>( @@ -957,7 +957,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload where dispatch could accept 0 arguments. function useReducer>( @@ -973,7 +973,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload where "I" may be a subset of ReducerState; used to provide autocompletion. // If "I" matches ReducerState exactly then the last overload will allow initializer to be omitted. @@ -991,7 +991,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // overload for free "I"; all goes as long as initializer converts it into "ReducerState". function useReducer, I>( @@ -1007,7 +1007,7 @@ declare namespace React { * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 - * @see https://react.dev/reference/react/useReducer + * @see {@link https://react.dev/reference/react/useReducer} */ // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary. @@ -1032,7 +1032,7 @@ declare namespace React { * value around similar to how you’d use instance fields in classes. * * @version 16.8.0 - * @see https://react.dev/reference/react/useRef + * @see {@link https://react.dev/reference/react/useRef} */ function useRef(initialValue: T): MutableRefObject; // convenience overload for refs given as a ref prop as they typically start with a null value @@ -1047,7 +1047,7 @@ declare namespace React { * of the generic argument. * * @version 16.8.0 - * @see https://react.dev/reference/react/useRef + * @see {@link https://react.dev/reference/react/useRef} */ function useRef(initialValue: T | null): RefObject; // convenience overload for potentially undefined initialValue / call with 0 arguments @@ -1060,7 +1060,7 @@ declare namespace React { * value around similar to how you’d use instance fields in classes. * * @version 16.8.0 - * @see https://react.dev/reference/react/useRef + * @see {@link https://react.dev/reference/react/useRef} */ function useRef(): MutableRefObject; /** @@ -1074,7 +1074,7 @@ declare namespace React { * `componentDidMount` and `componentDidUpdate`. * * @version 16.8.0 - * @see https://react.dev/reference/react/useLayoutEffect + * @see {@link https://react.dev/reference/react/useLayoutEffect} */ function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void; /** @@ -1084,7 +1084,7 @@ declare namespace React { * @param deps If present, effect will only activate if the values in the list change. * * @version 16.8.0 - * @see https://react.dev/reference/react/useEffect + * @see {@link https://react.dev/reference/react/useEffect} */ function useEffect(effect: EffectCallback, deps?: DependencyList): void; // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref @@ -1095,7 +1095,7 @@ declare namespace React { * `useImperativeHandle` should be used with `React.forwardRef`. * * @version 16.8.0 - * @see https://react.dev/reference/react/useImperativeHandle + * @see {@link https://react.dev/reference/react/useImperativeHandle} */ function useImperativeHandle(ref: Ref | undefined, init: () => R, deps?: DependencyList): void; // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key @@ -1105,7 +1105,7 @@ declare namespace React { * has changed. * * @version 16.8.0 - * @see https://react.dev/reference/react/useCallback + * @see {@link https://react.dev/reference/react/useCallback} */ // TODO (TypeScript 3.0): unknown> function useCallback any>(callback: T, deps: DependencyList): T; @@ -1113,7 +1113,7 @@ declare namespace React { * `useMemo` will only recompute the memoized value when one of the `deps` has changed. * * @version 16.8.0 - * @see https://react.dev/reference/react/useMemo + * @see {@link https://react.dev/reference/react/useMemo} */ // allow undefined, but don't make it optional as that is very likely a mistake function useMemo(factory: () => T, deps: DependencyList | undefined): T; @@ -1124,7 +1124,7 @@ declare namespace React { * It’s most valuable for custom hooks that are part of shared libraries. * * @version 16.8.0 - * @see https://react.dev/reference/react/useDebugValue + * @see {@link https://react.dev/reference/react/useDebugValue} */ // the name of the custom hook is itself derived from the function name at runtime: // it's just the function name without the "use" prefix. @@ -1947,12 +1947,12 @@ declare namespace React { // Living Standard /** * Hints at the type of data that might be entered by the user while editing the element or its contents - * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute + * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute} */ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined; /** * Specify that a standard HTML element should behave like a defined custom built-in element - * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is + * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is} */ is?: string | undefined; /** diff --git a/types/react/v18/canary.d.ts b/types/react/v18/canary.d.ts index 840f5892f8f3d0..036cf1f8987461 100644 --- a/types/react/v18/canary.d.ts +++ b/types/react/v18/canary.d.ts @@ -53,7 +53,7 @@ declare module "." { * context value, as given by the nearest context provider for the given context. * * @version 16.8.0 - * @see https://react.dev/reference/react/useContext + * @see {@link https://react.dev/reference/react/useContext} */ function useContext(context: ServerContext): T; export function createServerContext( diff --git a/types/react/v18/experimental.d.ts b/types/react/v18/experimental.d.ts index 3b71d14592b7ee..5f05fbaf5d37ae 100644 --- a/types/react/v18/experimental.d.ts +++ b/types/react/v18/experimental.d.ts @@ -101,8 +101,8 @@ declare module "." { * However, if you wrap these items in a `SuspenseList`, React will not show an item in the list * until previous items have been displayed (this behavior is adjustable). * - * @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist - * @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist + * @see {@link https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist} + * @see {@link https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist} */ export const unstable_SuspenseList: ExoticComponent; @@ -125,7 +125,7 @@ declare module "." { export interface HTMLAttributes { /** - * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert} */ inert?: boolean | undefined; } diff --git a/types/react/v18/index.d.ts b/types/react/v18/index.d.ts index 5756cd7ec65f33..1673098eae63eb 100644 --- a/types/react/v18/index.d.ts +++ b/types/react/v18/index.d.ts @@ -2149,7 +2149,7 @@ declare namespace React { * * @param callback A synchronous, void callback that will execute as a single, complete React commit. * - * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks + * @see {@link https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks} */ // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules. export function act(callback: () => VoidOrUndefinedOnly): void; diff --git a/types/react/v18/ts5.0/canary.d.ts b/types/react/v18/ts5.0/canary.d.ts index 840f5892f8f3d0..036cf1f8987461 100644 --- a/types/react/v18/ts5.0/canary.d.ts +++ b/types/react/v18/ts5.0/canary.d.ts @@ -53,7 +53,7 @@ declare module "." { * context value, as given by the nearest context provider for the given context. * * @version 16.8.0 - * @see https://react.dev/reference/react/useContext + * @see {@link https://react.dev/reference/react/useContext} */ function useContext(context: ServerContext): T; export function createServerContext( diff --git a/types/react/v18/ts5.0/experimental.d.ts b/types/react/v18/ts5.0/experimental.d.ts index 3b71d14592b7ee..5f05fbaf5d37ae 100644 --- a/types/react/v18/ts5.0/experimental.d.ts +++ b/types/react/v18/ts5.0/experimental.d.ts @@ -101,8 +101,8 @@ declare module "." { * However, if you wrap these items in a `SuspenseList`, React will not show an item in the list * until previous items have been displayed (this behavior is adjustable). * - * @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist - * @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist + * @see {@link https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist} + * @see {@link https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist} */ export const unstable_SuspenseList: ExoticComponent; @@ -125,7 +125,7 @@ declare module "." { export interface HTMLAttributes { /** - * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert} */ inert?: boolean | undefined; } diff --git a/types/react/v18/ts5.0/index.d.ts b/types/react/v18/ts5.0/index.d.ts index e14b69a5d1fa53..b5446b5f670f66 100644 --- a/types/react/v18/ts5.0/index.d.ts +++ b/types/react/v18/ts5.0/index.d.ts @@ -2150,7 +2150,7 @@ declare namespace React { * * @param callback A synchronous, void callback that will execute as a single, complete React commit. * - * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks + * @see {@link https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks} */ // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules. export function act(callback: () => VoidOrUndefinedOnly): void; From 4d0de1c1e2b9fd71f3a226535690b1c66e2b2112 Mon Sep 17 00:00:00 2001 From: "Sebastian \"Sebbie\" Silbermann" Date: Thu, 5 Feb 2026 11:04:54 +0100 Subject: [PATCH 14/14] [react] Backport recent changes to TS 5.0 fork (#74452) --- types/react/test/hooks.tsx | 2 +- types/react/test/managedAttributes.tsx | 2 +- types/react/ts5.0/index.d.ts | 3 +++ types/react/ts5.0/test/elementAttributes.tsx | 3 +++ types/react/ts5.0/test/index.ts | 15 +++++++-------- types/react/ts5.0/tsconfig.json | 3 ++- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/types/react/test/hooks.tsx b/types/react/test/hooks.tsx index 94fc2a6f310bd8..852c5b81839c44 100644 --- a/types/react/test/hooks.tsx +++ b/types/react/test/hooks.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; const { useSyncExternalStore } = React; diff --git a/types/react/test/managedAttributes.tsx b/types/react/test/managedAttributes.tsx index 2e122f5d3577be..3866bdadca1ea0 100644 --- a/types/react/test/managedAttributes.tsx +++ b/types/react/test/managedAttributes.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; interface Props { bool?: boolean; diff --git a/types/react/ts5.0/index.d.ts b/types/react/ts5.0/index.d.ts index a57ee49ea69509..c9bac1033c8e85 100644 --- a/types/react/ts5.0/index.d.ts +++ b/types/react/ts5.0/index.d.ts @@ -3598,6 +3598,9 @@ declare namespace React { method?: string | undefined; min?: number | string | undefined; name?: string | undefined; + nonce?: string | undefined; + part?: string | undefined; + slot?: string | undefined; style?: CSSProperties | undefined; target?: string | undefined; type?: string | undefined; diff --git a/types/react/ts5.0/test/elementAttributes.tsx b/types/react/ts5.0/test/elementAttributes.tsx index 22e7be732eb7ae..b9e3a8837d5238 100644 --- a/types/react/ts5.0/test/elementAttributes.tsx +++ b/types/react/ts5.0/test/elementAttributes.tsx @@ -29,6 +29,7 @@ const testCases = [ , , , + , , , , @@ -101,6 +102,7 @@ const testCases = [ open />, , + ,

, // Float <> @@ -171,6 +173,7 @@ const testCases = [ <> , diff --git a/types/react/ts5.0/test/index.ts b/types/react/ts5.0/test/index.ts index 9ccad10ff80b3e..0feda13a9488d6 100644 --- a/types/react/ts5.0/test/index.ts +++ b/types/react/ts5.0/test/index.ts @@ -135,17 +135,16 @@ class ModernComponent extends React.Component implements static propTypes = {}; static contextType = SomeContext; - context: Context; + declare context: Context; constructor(props: Props, context: Context) { super(props, context); + this.state = { + inputValue: this.context.someValue, + seconds: this.props.foo, + }; } - state = { - inputValue: this.context.someValue, - seconds: this.props.foo, - }; - reset() { this._myComponent.reset(); this.setState({ @@ -154,8 +153,8 @@ class ModernComponent extends React.Component implements }); } - private readonly _myComponent: MyComponent; - private _input: HTMLInputElement | null; + private readonly _myComponent!: MyComponent; + private _input: HTMLInputElement | null = null; render() { return React.createElement( diff --git a/types/react/ts5.0/tsconfig.json b/types/react/ts5.0/tsconfig.json index 61a90f21879ce5..f4fa9ad4f5810d 100644 --- a/types/react/ts5.0/tsconfig.json +++ b/types/react/ts5.0/tsconfig.json @@ -25,6 +25,7 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "jsx": "preserve" + "jsx": "preserve", + "esModuleInterop": true } }