diff --git a/types/activex-adodb/activex-adodb-tests.ts b/types/activex-adodb/activex-adodb-tests.ts index e9312dc2a075c8..9917f6613fe79a 100644 --- a/types/activex-adodb/activex-adodb-tests.ts +++ b/types/activex-adodb/activex-adodb-tests.ts @@ -96,7 +96,7 @@ const withConnection = (initialCatalog: string, fn: (conn: ADODB.Connection) => try { conn.Open(connectionString); fn(conn); - } catch (e) { + } catch (e: any) { WScript.Echo(e.message); } finally { if (conn.State === ADODB.ObjectStateEnum.adStateOpen) { @@ -134,7 +134,7 @@ const withRs = ( rs = tableOrCommand.Execute() as ADODB.Recordset; } fn(rs); - } catch (e) { + } catch (e: any) { WScript.Echo(e.message); } finally { if (rs && rs.State === ADODB.ObjectStateEnum.adStateOpen) { @@ -252,7 +252,7 @@ const withEmployees = (fn: (rs: ADODB.Recordset) => void, type: ADODB.CursorType WScript.Echo(rsContact("ContactName")); rsContact.MoveNext(); } - } catch (e) { + } catch (e: any) { WScript.Echo(e.message); } finally { if (rsContact && rsContact.State === ADODB.ObjectStateEnum.adStateOpen) { diff --git a/types/activex-msxml2/activex-msxml2-tests.ts b/types/activex-msxml2/activex-msxml2-tests.ts index 8ab34f9c23e8b4..0f55f431dfe8a4 100644 --- a/types/activex-msxml2/activex-msxml2-tests.ts +++ b/types/activex-msxml2/activex-msxml2-tests.ts @@ -23,7 +23,7 @@ const MakeDOM = () => { dom.validateOnParse = false; dom.resolveExternals = false; return dom; - } catch (e) { + } catch (e: any) { WScript.Echo(e.description); } }; @@ -33,7 +33,7 @@ const LoadDOM = (file: string) => { const dom = MakeDOM()!; dom.load(file); return dom; - } catch (e) { + } catch (e: any) { WScript.Echo(e.description); } }; @@ -171,7 +171,7 @@ const LoadDOM = (file: string) => { if (nextNode == null) continue; WScript.Echo(`Node (${i}), <${oNode.nodeName} + ">:\n\t${oNode.xml}`); } - } catch (e) { + } catch (e: any) { WScript.Echo(e.description); } } diff --git a/types/alt/alt-tests.ts b/types/alt/alt-tests.ts index 96109bcbb883d7..b6db75ba2d9bc2 100644 --- a/types/alt/alt-tests.ts +++ b/types/alt/alt-tests.ts @@ -22,19 +22,19 @@ interface TestActionsExplicit { class AbstractActions implements AltJS.ActionsClass { constructor(alt: AltJS.Alt) {} actions: any; - dispatch: (...payload: any[]) => void; - generateActions: (...actions: string[]) => void; + dispatch!: (...payload: any[]) => void; + generateActions!: (...actions: string[]) => void; } class AbstractStoreModel implements AltJS.StoreModel { - bindActions: (...actions: Object[]) => void; - bindAction: (...args: any[]) => void; - bindListeners: (obj: any) => void; - exportPublicMethods: (config: { [key: string]: (...args: any[]) => any }) => any; - exportAsync: (source: any) => void; + bindActions!: (...actions: Object[]) => void; + bindAction!: (...args: any[]) => void; + bindListeners!: (obj: any) => void; + exportPublicMethods!: (config: { [key: string]: (...args: any[]) => any }) => any; + exportAsync!: (source: any) => void; waitFor: any; exportConfig: any; - getState: () => S; + getState!: () => S; } class GenerateActionsClass extends AbstractActions { diff --git a/types/angular-es/angular-es-tests.ts b/types/angular-es/angular-es-tests.ts index 8b014fe5767c73..59c34c2c748e52 100644 --- a/types/angular-es/angular-es-tests.ts +++ b/types/angular-es/angular-es-tests.ts @@ -95,7 +95,7 @@ import { InjectAsProperty } from "angular-es"; @InjectAsProperty("fooBar") class MyFooBarService { - fooBar: Object; + fooBar!: Object; myMethod() { this.fooBar !== undefined; diff --git a/types/appletvjs/appletvjs-tests.ts b/types/appletvjs/appletvjs-tests.ts index a2af380e99023c..c4d178677d54ea 100644 --- a/types/appletvjs/appletvjs-tests.ts +++ b/types/appletvjs/appletvjs-tests.ts @@ -31,8 +31,8 @@ function test_FeatureElement() { "", "application/xml", ); - var textField = document.getElementById("textField"); - textField.addEventListener("change", function() { + var textField = document.getElementById("textField") as unknown as AppleTVJS.FeatureElement; + textField.addEventListener("change", function(this: AppleTVJS.FeatureElement) { change.call(this, textField); }); @@ -42,8 +42,8 @@ function test_FeatureElement() { var text = keyboard.text; }; - var menuBar = document.getElementById("menuBar"); - textField.addEventListener("change", function() { + var menuBar = document.getElementById("menuBar") as unknown as AppleTVJS.FeatureElement; + textField.addEventListener("change", function(this: AppleTVJS.FeatureElement) { change.call(this, textField); }); diff --git a/types/arangodb/arangodb-tests.ts b/types/arangodb/arangodb-tests.ts index 566dea7a04b833..dbe332896d9614 100644 --- a/types/arangodb/arangodb-tests.ts +++ b/types/arangodb/arangodb-tests.ts @@ -117,7 +117,7 @@ router.put( params: JSON.parse(request.body), }); response.json({ id }); - } catch (e) { + } catch (e: any) { e.error = true; response.json(e); } diff --git a/types/ari-client/test/ari-client-tests.externalMedia.ts b/types/ari-client/test/ari-client-tests.externalMedia.ts index 8b480e2ef37c97..8fee138d419786 100644 --- a/types/ari-client/test/ari-client-tests.externalMedia.ts +++ b/types/ari-client/test/ari-client-tests.externalMedia.ts @@ -6,7 +6,7 @@ import { EventEmitter } from "events"; export default class TsgBridge extends EventEmitter { ariClient: Client; - bridge: Bridge; + bridge!: Bridge; constructor(ariClient: Client, exten: string, log: any) { super(); diff --git a/types/athenajs/test/tetris/grid.ts b/types/athenajs/test/tetris/grid.ts index 457a7d858bfde8..072bbb57a8d42a 100644 --- a/types/athenajs/test/tetris/grid.ts +++ b/types/athenajs/test/tetris/grid.ts @@ -31,23 +31,23 @@ class Grid extends Scene { // game sprites // current tetris shape - shape: Shape; + shape!: Shape; // next tetris shape - nextShape: Shape; + nextShape!: Shape; // next tetris string - nextString: SimpleText; + nextString!: SimpleText; // score - scoreString: SimpleText; + scoreString!: SimpleText; // "line:" - linesString: SimpleText; + linesString!: SimpleText; // "level:" - levelString: SimpleText; + levelString!: SimpleText; // "pause:" - pauseString: SimpleText; + pauseString!: SimpleText; // flashing lines - flashLines: FlashLines; + flashLines!: FlashLines; // ->, <- - controls: SimpleText; + controls!: SimpleText; constructor() { super({ diff --git a/types/athenajs/test/tetris/shape.ts b/types/athenajs/test/tetris/shape.ts index 653179ffdf5a4d..27b418e772689d 100644 --- a/types/athenajs/test/tetris/shape.ts +++ b/types/athenajs/test/tetris/shape.ts @@ -12,10 +12,10 @@ interface shapeDescription { class Shape extends Sprite { shapes: shapeDescription[]; // current shape - shape: shapeDescription; - shapeName: string; + shape!: shapeDescription; + shapeName!: string; // current shape rotation - rotation: number; + rotation!: number; constructor(name: string, options = {}) { super(name, { diff --git a/types/athenajs/test/tetris/shape_behavior.ts b/types/athenajs/test/tetris/shape_behavior.ts index 182a161f55b3c6..596d56b78040aa 100644 --- a/types/athenajs/test/tetris/shape_behavior.ts +++ b/types/athenajs/test/tetris/shape_behavior.ts @@ -13,10 +13,10 @@ class ShapeBehavior extends Behavior { ts: number; LONG_DELAY: number; SMALL_DELAY: number; - delay: number; - key: number; - timerEnabled: boolean; - startTime: number; + delay!: number; + key!: number; + timerEnabled!: boolean; + startTime!: number; constructor(sprite: Shape, options?: any) { super(sprite as Drawable, options); diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index 9d7e7f40d1c186..499bb1006c349f 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -654,7 +654,7 @@ function testDecoration() { // DeserializerManager ======================================================== function testDesializerManager() { class StorableClass { - name: string; + name!: string; constructor() {} deserialize() { diff --git a/types/backbone.marionette/backbone.marionette-tests.ts b/types/backbone.marionette/backbone.marionette-tests.ts index 8b7be0f1a5d91f..beb8d5fc41bd91 100644 --- a/types/backbone.marionette/backbone.marionette-tests.ts +++ b/types/backbone.marionette/backbone.marionette-tests.ts @@ -57,8 +57,8 @@ class MyApplication extends Marionette.Application { this.layoutView = new AppLayoutView(); } - layoutView: AppLayoutView; - mainRegion: Marionette.Region; + layoutView!: AppLayoutView; + mainRegion!: Marionette.Region; onStart() { this.mainRegion = new Marionette.Region({ el: "#main" }); diff --git a/types/backbone/backbone-tests.ts b/types/backbone/backbone-tests.ts index 7a339fd14d34d6..d81afc30ed9d38 100644 --- a/types/backbone/backbone-tests.ts +++ b/types/backbone/backbone-tests.ts @@ -21,16 +21,16 @@ function test_events() { } class PubSub implements Backbone.Events { - on: Backbone.Events_On; - off: Backbone.Events_Off; - trigger: Backbone.Events_Trigger; - bind: Backbone.Events_On; - unbind: Backbone.Events_Off; - - once: Backbone.Events_On; - listenTo: Backbone.Events_Listen; - listenToOnce: Backbone.Events_Listen; - stopListening: Backbone.Events_Stop; + on!: Backbone.Events_On; + off!: Backbone.Events_Off; + trigger!: Backbone.Events_Trigger; + bind!: Backbone.Events_On; + unbind!: Backbone.Events_Off; + + once!: Backbone.Events_On; + listenTo!: Backbone.Events_Listen; + listenToOnce!: Backbone.Events_Listen; + stopListening!: Backbone.Events_Stop; } Object.assign(PubSub.prototype, Backbone.Events); @@ -156,7 +156,7 @@ class PrivateNote extends Note { } set(attributes: any, options?: any): this { - return Backbone.Model.prototype.set.call(this, attributes, options); + return super.set(attributes, options); } } @@ -217,9 +217,9 @@ class EmployeeCollection extends Backbone.Collection { } class Book extends Backbone.Model { - title: string; - author: string; - published: boolean; + title!: string; + author!: string; + published!: boolean; } class Library extends Backbone.Collection { diff --git a/types/bardjs/bardjs-tests.ts b/types/bardjs/bardjs-tests.ts index 89942203079fb6..d4e4ccc2fcc5a0 100644 --- a/types/bardjs/bardjs-tests.ts +++ b/types/bardjs/bardjs-tests.ts @@ -23,7 +23,7 @@ namespace myService { } class MyController { - myProperty: string; + myProperty!: string; } angular diff --git a/types/blessed/blessed-tests.ts b/types/blessed/blessed-tests.ts index 8d8d44860c155d..6a4e0ed9c42c3a 100644 --- a/types/blessed/blessed-tests.ts +++ b/types/blessed/blessed-tests.ts @@ -110,7 +110,7 @@ const lorem = readFileSync(__dirname + "/git.diff", "utf8"); const cleanSides = screen.cleanSides; function expectClean(value: any) { screen.cleanSides = function(el: blessed.Widgets.BlessedElement) { - const ret = cleanSides.apply(this, arguments); + const ret = cleanSides.call(this, el); if (ret !== value) { throw new Error(`Failed. Expected ${value} from cleanSides. Got ${ret}.`); } diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index 58b9bea3dc2763..29323be51f835e 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -366,7 +366,7 @@ fooOrBarProm = fooProm.caught(Bluebird.CancellationError, (reason: any) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - class CustomError extends Error { - customField: number; + customField!: number; } // $ExpectType Bluebird fooProm.catch(CustomError, reason => { diff --git a/types/braintree-web/test/web.ts b/types/braintree-web/test/web.ts index bf8f56e4b205c6..6a8e8d49cb7c53 100644 --- a/types/braintree-web/test/web.ts +++ b/types/braintree-web/test/web.ts @@ -668,7 +668,7 @@ braintree.client.create( }); payload.nonce; // Submit payload.nonce to your server - } catch (tokenizeErr /*braintree.BraintreeError*/) { + } catch (tokenizeErr: any) { // Handle tokenization errors or premature flow closure switch (tokenizeErr.code) { case "PAYPAL_POPUP_CLOSED": diff --git a/types/buffer-more-ints/.npmignore b/types/buffer-more-ints/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/buffer-more-ints/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/buffer-more-ints/buffer-more-ints-tests.ts b/types/buffer-more-ints/buffer-more-ints-tests.ts new file mode 100644 index 00000000000000..7a0761c9cf61b9 --- /dev/null +++ b/types/buffer-more-ints/buffer-more-ints-tests.ts @@ -0,0 +1,152 @@ +import * as moreInts from "buffer-more-ints"; +import "buffer-more-ints/polyfill"; +import { Buffer } from "buffer"; + +// Test isContiguousInt and assertContiguousInt +const isContiguous: boolean = moreInts.isContiguousInt(12345); +moreInts.assertContiguousInt(12345); + +// Create a test buffer +const buf = Buffer.alloc(16); + +// Test standalone functions - read operations +const u8: number = moreInts.readUInt8(buf, 0); +const i8: number = moreInts.readInt8(buf, 0); + +const u16be: number = moreInts.readUInt16BE(buf, 0); +const u16le: number = moreInts.readUInt16LE(buf, 0); +const i16be: number = moreInts.readInt16BE(buf, 0); +const i16le: number = moreInts.readInt16LE(buf, 0); + +const u24be: number = moreInts.readUInt24BE(buf, 0); +const u24le: number = moreInts.readUInt24LE(buf, 0); +const i24be: number = moreInts.readInt24BE(buf, 0); +const i24le: number = moreInts.readInt24LE(buf, 0); + +const u32be: number = moreInts.readUInt32BE(buf, 0); +const u32le: number = moreInts.readUInt32LE(buf, 0); +const i32be: number = moreInts.readInt32BE(buf, 0); +const i32le: number = moreInts.readInt32LE(buf, 0); + +const u40be: number = moreInts.readUInt40BE(buf, 0); +const u40le: number = moreInts.readUInt40LE(buf, 0); +const i40be: number = moreInts.readInt40BE(buf, 0); +const i40le: number = moreInts.readInt40LE(buf, 0); + +const u48be: number = moreInts.readUInt48BE(buf, 0); +const u48le: number = moreInts.readUInt48LE(buf, 0); +const i48be: number = moreInts.readInt48BE(buf, 0); +const i48le: number = moreInts.readInt48LE(buf, 0); + +const u56be: number = moreInts.readUInt56BE(buf, 0); +const u56le: number = moreInts.readUInt56LE(buf, 0); +const i56be: number = moreInts.readInt56BE(buf, 0); +const i56le: number = moreInts.readInt56LE(buf, 0); + +const u64be: number = moreInts.readUInt64BE(buf, 0); +const u64le: number = moreInts.readUInt64LE(buf, 0); +const i64be: number = moreInts.readInt64BE(buf, 0); +const i64le: number = moreInts.readInt64LE(buf, 0); + +// Test standalone functions - write operations +moreInts.writeUInt8(buf, 255, 0); +moreInts.writeInt8(buf, -128, 0); + +moreInts.writeUInt16BE(buf, 0xffff, 0); +moreInts.writeUInt16LE(buf, 0xffff, 0); +moreInts.writeInt16BE(buf, -32768, 0); +moreInts.writeInt16LE(buf, -32768, 0); + +moreInts.writeUInt24BE(buf, 0xffffff, 0); +moreInts.writeUInt24LE(buf, 0xffffff, 0); +moreInts.writeInt24BE(buf, -8388608, 0); +moreInts.writeInt24LE(buf, -8388608, 0); + +moreInts.writeUInt32BE(buf, 0xffffffff, 0); +moreInts.writeUInt32LE(buf, 0xffffffff, 0); +moreInts.writeInt32BE(buf, -2147483648, 0); +moreInts.writeInt32LE(buf, -2147483648, 0); + +moreInts.writeUInt40BE(buf, 0xffffffffff, 0); +moreInts.writeUInt40LE(buf, 0xffffffffff, 0); +moreInts.writeInt40BE(buf, -549755813888, 0); +moreInts.writeInt40LE(buf, -549755813888, 0); + +moreInts.writeUInt48BE(buf, 0xffffffffffff, 0); +moreInts.writeUInt48LE(buf, 0xffffffffffff, 0); +moreInts.writeInt48BE(buf, -140737488355328, 0); +moreInts.writeInt48LE(buf, -140737488355328, 0); + +moreInts.writeUInt56BE(buf, 0xffffffffffffff, 0); +moreInts.writeUInt56LE(buf, 0xffffffffffffff, 0); +moreInts.writeInt56BE(buf, 0x7fffffffffffff, 0); +moreInts.writeInt56LE(buf, 0x7fffffffffffff, 0); + +moreInts.writeUInt64BE(buf, 0xffffffffffffffff, 0); +moreInts.writeUInt64LE(buf, 0xffffffffffffffff, 0); +moreInts.writeInt64BE(buf, 0x7fffffffffffffff, 0); +moreInts.writeInt64LE(buf, 0x7fffffffffffffff, 0); + +// Test polyfill - static methods on Buffer +const isContiguousPolyfill: boolean = Buffer.isContiguousInt(12345); +Buffer.assertContiguousInt(12345); + +// Test polyfill - Buffer.prototype methods for 24-bit +const pu24be: number = buf.readUInt24BE(0); +const pu24le: number = buf.readUInt24LE(0); +const pi24be: number = buf.readInt24BE(0); +const pi24le: number = buf.readInt24LE(0); +buf.writeUInt24BE(0xffffff, 0); +buf.writeUInt24LE(0xffffff, 0); +buf.writeInt24BE(-8388608, 0); +buf.writeInt24LE(-8388608, 0); + +// Test polyfill - Buffer.prototype methods for 40-bit +const pu40be: number = buf.readUInt40BE(0); +const pu40le: number = buf.readUInt40LE(0); +const pi40be: number = buf.readInt40BE(0); +const pi40le: number = buf.readInt40LE(0); +buf.writeUInt40BE(0xffffffffff, 0); +buf.writeUInt40LE(0xffffffffff, 0); +buf.writeInt40BE(-549755813888, 0); +buf.writeInt40LE(-549755813888, 0); + +// Test polyfill - Buffer.prototype methods for 48-bit +const pu48be: number = buf.readUInt48BE(0); +const pu48le: number = buf.readUInt48LE(0); +const pi48be: number = buf.readInt48BE(0); +const pi48le: number = buf.readInt48LE(0); +buf.writeUInt48BE(0xffffffffffff, 0); +buf.writeUInt48LE(0xffffffffffff, 0); +buf.writeInt48BE(-140737488355328, 0); +buf.writeInt48LE(-140737488355328, 0); + +// Test polyfill - Buffer.prototype methods for 56-bit +const pu56be: number = buf.readUInt56BE(0); +const pu56le: number = buf.readUInt56LE(0); +const pi56be: number = buf.readInt56BE(0); +const pi56le: number = buf.readInt56LE(0); +buf.writeUInt56BE(0xffffffffffffff, 0); +buf.writeUInt56LE(0xffffffffffffff, 0); +buf.writeInt56BE(0x7fffffffffffff, 0); +buf.writeInt56LE(0x7fffffffffffff, 0); + +// Test polyfill - Buffer.prototype methods for 64-bit +const pu64be: number = buf.readUInt64BE(0); +const pu64le: number = buf.readUInt64LE(0); +const pi64be: number = buf.readInt64BE(0); +const pi64le: number = buf.readInt64LE(0); +buf.writeUInt64BE(0xffffffffffffffff, 0); +buf.writeUInt64LE(0xffffffffffffffff, 0); +buf.writeInt64BE(0x7fffffffffffffff, 0); +buf.writeInt64LE(0x7fffffffffffffff, 0); + +// Test polyfill - generic methods with length parameter +const genericUIntBE: number = buf.readUIntBE(3, 0); +const genericUIntLE: number = buf.readUIntLE(4, 0); +const genericIntBE: number = buf.readIntBE(5, 0); +const genericIntLE: number = buf.readIntLE(6, 0); +buf.writeUIntBE(3, 0xffffff, 0); +buf.writeUIntLE(4, 0xffffffff, 0); +buf.writeIntBE(5, -549755813888, 0); +buf.writeIntLE(6, -140737488355328, 0); diff --git a/types/buffer-more-ints/index.d.ts b/types/buffer-more-ints/index.d.ts new file mode 100644 index 00000000000000..ed46b883b4145e --- /dev/null +++ b/types/buffer-more-ints/index.d.ts @@ -0,0 +1,94 @@ +/// + +import { Buffer } from "buffer"; + +/** + * Checks if a value can be represented as a contiguous integer + * (i.e., it's within the range that can be exactly represented by IEEE754 doubles). + * @param val The value to check + * @returns true if the value can be represented exactly + */ +export function isContiguousInt(val: number): boolean; + +/** + * Throws a TypeError if the value cannot be represented as a contiguous integer. + * @param val The value to check + * @throws TypeError if the value cannot be represented as a contiguous integer + */ +export function assertContiguousInt(val: number): void; + +// 8-bit integers +export function readUInt8(buf: Buffer, offset: number): number; +export function writeUInt8(buf: Buffer, val: number, offset: number): void; +export function readInt8(buf: Buffer, offset: number): number; +export function writeInt8(buf: Buffer, val: number, offset: number): void; + +// 16-bit integers +export function readUInt16BE(buf: Buffer, offset: number): number; +export function writeUInt16BE(buf: Buffer, val: number, offset: number): void; +export function readUInt16LE(buf: Buffer, offset: number): number; +export function writeUInt16LE(buf: Buffer, val: number, offset: number): void; +export function readInt16BE(buf: Buffer, offset: number): number; +export function writeInt16BE(buf: Buffer, val: number, offset: number): void; +export function readInt16LE(buf: Buffer, offset: number): number; +export function writeInt16LE(buf: Buffer, val: number, offset: number): void; + +// 24-bit integers +export function readUInt24BE(buf: Buffer, offset: number): number; +export function writeUInt24BE(buf: Buffer, val: number, offset: number): void; +export function readUInt24LE(buf: Buffer, offset: number): number; +export function writeUInt24LE(buf: Buffer, val: number, offset: number): void; +export function readInt24BE(buf: Buffer, offset: number): number; +export function writeInt24BE(buf: Buffer, val: number, offset: number): void; +export function readInt24LE(buf: Buffer, offset: number): number; +export function writeInt24LE(buf: Buffer, val: number, offset: number): void; + +// 32-bit integers +export function readUInt32BE(buf: Buffer, offset: number): number; +export function writeUInt32BE(buf: Buffer, val: number, offset: number): void; +export function readUInt32LE(buf: Buffer, offset: number): number; +export function writeUInt32LE(buf: Buffer, val: number, offset: number): void; +export function readInt32BE(buf: Buffer, offset: number): number; +export function writeInt32BE(buf: Buffer, val: number, offset: number): void; +export function readInt32LE(buf: Buffer, offset: number): number; +export function writeInt32LE(buf: Buffer, val: number, offset: number): void; + +// 40-bit integers +export function readUInt40BE(buf: Buffer, offset: number): number; +export function writeUInt40BE(buf: Buffer, val: number, offset: number): void; +export function readUInt40LE(buf: Buffer, offset: number): number; +export function writeUInt40LE(buf: Buffer, val: number, offset: number): void; +export function readInt40BE(buf: Buffer, offset: number): number; +export function writeInt40BE(buf: Buffer, val: number, offset: number): void; +export function readInt40LE(buf: Buffer, offset: number): number; +export function writeInt40LE(buf: Buffer, val: number, offset: number): void; + +// 48-bit integers +export function readUInt48BE(buf: Buffer, offset: number): number; +export function writeUInt48BE(buf: Buffer, val: number, offset: number): void; +export function readUInt48LE(buf: Buffer, offset: number): number; +export function writeUInt48LE(buf: Buffer, val: number, offset: number): void; +export function readInt48BE(buf: Buffer, offset: number): number; +export function writeInt48BE(buf: Buffer, val: number, offset: number): void; +export function readInt48LE(buf: Buffer, offset: number): number; +export function writeInt48LE(buf: Buffer, val: number, offset: number): void; + +// 56-bit integers +export function readUInt56BE(buf: Buffer, offset: number): number; +export function writeUInt56BE(buf: Buffer, val: number, offset: number): void; +export function readUInt56LE(buf: Buffer, offset: number): number; +export function writeUInt56LE(buf: Buffer, val: number, offset: number): void; +export function readInt56BE(buf: Buffer, offset: number): number; +export function writeInt56BE(buf: Buffer, val: number, offset: number): void; +export function readInt56LE(buf: Buffer, offset: number): number; +export function writeInt56LE(buf: Buffer, val: number, offset: number): void; + +// 64-bit integers +export function readUInt64BE(buf: Buffer, offset: number): number; +export function writeUInt64BE(buf: Buffer, val: number, offset: number): void; +export function readUInt64LE(buf: Buffer, offset: number): number; +export function writeUInt64LE(buf: Buffer, val: number, offset: number): void; +export function readInt64BE(buf: Buffer, offset: number): number; +export function writeInt64BE(buf: Buffer, val: number, offset: number): void; +export function readInt64LE(buf: Buffer, offset: number): number; +export function writeInt64LE(buf: Buffer, val: number, offset: number): void; diff --git a/types/buffer-more-ints/package.json b/types/buffer-more-ints/package.json new file mode 100644 index 00000000000000..de5c0659da1988 --- /dev/null +++ b/types/buffer-more-ints/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/buffer-more-ints", + "version": "1.0.9999", + "projects": [ + "https://github.com/dpw/node-buffer-more-ints" + ], + "dependencies": { + "@types/node": "*" + }, + "devDependencies": { + "@types/buffer-more-ints": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/buffer-more-ints/polyfill.d.ts b/types/buffer-more-ints/polyfill.d.ts new file mode 100644 index 00000000000000..fbc6dea63829ce --- /dev/null +++ b/types/buffer-more-ints/polyfill.d.ts @@ -0,0 +1,79 @@ +/// + +declare global { + interface BufferConstructor { + /** + * Checks if a value can be represented as a contiguous integer. + */ + isContiguousInt(val: number): boolean; + + /** + * Throws a TypeError if the value cannot be represented as a contiguous integer. + */ + assertContiguousInt(val: number): void; + } + + interface Buffer { + // 24-bit integers + readUInt24BE(offset: number): number; + writeUInt24BE(val: number, offset: number): void; + readUInt24LE(offset: number): number; + writeUInt24LE(val: number, offset: number): void; + readInt24BE(offset: number): number; + writeInt24BE(val: number, offset: number): void; + readInt24LE(offset: number): number; + writeInt24LE(val: number, offset: number): void; + + // 40-bit integers + readUInt40BE(offset: number): number; + writeUInt40BE(val: number, offset: number): void; + readUInt40LE(offset: number): number; + writeUInt40LE(val: number, offset: number): void; + readInt40BE(offset: number): number; + writeInt40BE(val: number, offset: number): void; + readInt40LE(offset: number): number; + writeInt40LE(val: number, offset: number): void; + + // 48-bit integers + readUInt48BE(offset: number): number; + writeUInt48BE(val: number, offset: number): void; + readUInt48LE(offset: number): number; + writeUInt48LE(val: number, offset: number): void; + readInt48BE(offset: number): number; + writeInt48BE(val: number, offset: number): void; + readInt48LE(offset: number): number; + writeInt48LE(val: number, offset: number): void; + + // 56-bit integers + readUInt56BE(offset: number): number; + writeUInt56BE(val: number, offset: number): void; + readUInt56LE(offset: number): number; + writeUInt56LE(val: number, offset: number): void; + readInt56BE(offset: number): number; + writeInt56BE(val: number, offset: number): void; + readInt56LE(offset: number): number; + writeInt56LE(val: number, offset: number): void; + + // 64-bit integers + readUInt64BE(offset: number): number; + writeUInt64BE(val: number, offset: number): void; + readUInt64LE(offset: number): number; + writeUInt64LE(val: number, offset: number): void; + readInt64BE(offset: number): number; + writeInt64BE(val: number, offset: number): void; + readInt64LE(offset: number): number; + writeInt64LE(val: number, offset: number): void; + + // Generic read/write methods with length parameter + readUIntBE(len: number, offset: number): number; + writeUIntBE(len: number, val: number, offset: number): void; + readUIntLE(len: number, offset: number): number; + writeUIntLE(len: number, val: number, offset: number): void; + readIntBE(len: number, offset: number): number; + writeIntBE(len: number, val: number, offset: number): void; + readIntLE(len: number, offset: number): number; + writeIntLE(len: number, val: number, offset: number): void; + } +} + +export {}; diff --git a/types/buffer-more-ints/tsconfig.json b/types/buffer-more-ints/tsconfig.json new file mode 100644 index 00000000000000..f12b65d13d3e91 --- /dev/null +++ b/types/buffer-more-ints/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "polyfill.d.ts", + "buffer-more-ints-tests.ts" + ] +} diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index 15a46234dc49bc..360f5e287ffa74 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -378,7 +378,7 @@ function deepInclude() { } class FakeArgs { - length: number; + length!: number; } function empty() { diff --git a/types/chai/v4/chai-tests.ts b/types/chai/v4/chai-tests.ts index ae6aec2278027f..9ec1f34a5e6418 100644 --- a/types/chai/v4/chai-tests.ts +++ b/types/chai/v4/chai-tests.ts @@ -532,7 +532,7 @@ function deepInclude() { } class FakeArgs { - length: number; + length!: number; } function empty() { diff --git a/types/code/code-tests.ts b/types/code/code-tests.ts index dda749ddf68c1d..61fdc6cfbc24f4 100644 --- a/types/code/code-tests.ts +++ b/types/code/code-tests.ts @@ -136,7 +136,7 @@ expect(1).to.match(/^\d$/); expect("x").to.satisfy(value => value === "x"); class CustomError extends Error { - call: (message: string) => Error; + call!: (message: string) => Error; } const throws = () => { diff --git a/types/codependency/codependency-tests.ts b/types/codependency/codependency-tests.ts index d56c6b8c8a12f3..377a620c61b62a 100644 --- a/types/codependency/codependency-tests.ts +++ b/types/codependency/codependency-tests.ts @@ -1,9 +1,9 @@ let requirePeer = codependency.register(module); -let package: any; +let pkg: any; requirePeer = codependency.register(module, { index: ["dependencies", "devDependencies"] }); requirePeer = codependency.get("some-middleware"); -package = requirePeer("some-peer-dependency-package"); -package = requirePeer("some-peer-dependency-package", { optional: true }); -package = requirePeer("some-peer-dependency-package", { dontThrow: true }); -package = requirePeer("some-peer-dependency-package", { optional: true, dontThrow: true }); -package = requirePeer.resolve("peer-package-name"); +pkg = requirePeer("some-peer-dependency-package"); +pkg = requirePeer("some-peer-dependency-package", { optional: true }); +pkg = requirePeer("some-peer-dependency-package", { dontThrow: true }); +pkg = requirePeer("some-peer-dependency-package", { optional: true, dontThrow: true }); +pkg = requirePeer.resolve("peer-package-name"); diff --git a/types/cors/cors-tests.ts b/types/cors/cors-tests.ts index b4934b51007000..b0eae42f017331 100644 --- a/types/cors/cors-tests.ts +++ b/types/cors/cors-tests.ts @@ -44,7 +44,7 @@ app.use(cors({ origin: (requestOrigin, cb) => { try { cb(null, true); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -53,7 +53,7 @@ app.use(cors({ origin: (requestOrigin, cb) => { try { cb(null, "http://example.com"); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -62,7 +62,7 @@ app.use(cors({ origin: (requestOrigin, cb) => { try { cb(null, /example\.com$/); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -71,7 +71,7 @@ app.use(cors({ origin: (requestOrigin, cb) => { try { cb(null, [/example\.com$/, "http://example.com"]); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -80,7 +80,7 @@ app.use(cors({ origin: (requestOrigin, cb) => { try { cb(null, ["http://example.com", "http://fakeurl.com"]); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -89,7 +89,7 @@ app.use(cors({ origin: (requestOrigin, cb) => { try { cb(null, [/example\.com$/, /fakeurl\.com$/]); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -101,7 +101,7 @@ app.use(cors({ throw new Error("No origin"); } cb(null, requestOrigin); - } catch (err) { + } catch (err: any) { cb(err); } }, @@ -111,7 +111,7 @@ app.use(cors({ try { const allow = !requestOrigin || requestOrigin.indexOf(".edu") !== -1; cb(null, allow); - } catch (err) { + } catch (err: any) { cb(err); } }, diff --git a/types/css-tree/css-tree-tests.ts b/types/css-tree/css-tree-tests.ts index 8b01356e5a0a2f..31fe806d75fee1 100644 --- a/types/css-tree/css-tree-tests.ts +++ b/types/css-tree/css-tree-tests.ts @@ -80,11 +80,11 @@ csstree.generate(ast, { }, node(node) { node; // $ExpectType CssNode - handlers.node.call(node); + handlers.node(node); }, chunk(chunk) { chunk; // $ExpectType string - handlers.chunk.call(chunk); + handlers.chunk(chunk); }, result() { return handlers.result.call(handlers); diff --git a/types/curtainsjs/curtainsjs-tests.ts b/types/curtainsjs/curtainsjs-tests.ts index 772bf51c0393c8..6ffee47abd5cf5 100644 --- a/types/curtainsjs/curtainsjs-tests.ts +++ b/types/curtainsjs/curtainsjs-tests.ts @@ -537,7 +537,7 @@ window.addEventListener("load", () => { class LocomotiveScroll { constructor(options: Record) {} - isMobile: boolean; + isMobile!: boolean; on( event: string, callback: (obj: { diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 31e3d5128633dc..c6de5d3b4bdda2 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -56,8 +56,8 @@ function stockPriceStream(ticker: string, const response = await fetch(url); const data = await response.json(); invocation.setResult(data.price); - } catch (error) { - invocation.setResult(error); + } catch (error: any) { + invocation.setResult(error); } isPending = false; }, updateFrequency); diff --git a/types/d/d-tests.ts b/types/d/d-tests.ts index 8faf59c03039ec..1a69b2d4245000 100644 --- a/types/d/d-tests.ts +++ b/types/d/d-tests.ts @@ -42,7 +42,7 @@ d.gs("ce", () => ({})); // $ExpectType PropertyDescriptor d.gs("cew", () => ({})); class Foo { - _count: number; + _count!: number; } Object.defineProperties( diff --git a/types/dashdash/dashdash-tests.ts b/types/dashdash/dashdash-tests.ts index a7883b792348ee..ebd9e7000589f8 100644 --- a/types/dashdash/dashdash-tests.ts +++ b/types/dashdash/dashdash-tests.ts @@ -36,7 +36,7 @@ console.log("args:", opts._args); const parser = dashdash.createParser({ options }); try { opts = parser.parse(process.argv); -} catch (e) { +} catch (e: any) { console.error("foo: error: %s", e.message); process.exit(1); } @@ -83,7 +83,7 @@ ${help}`); try { const opts = dashdash.parse({ options }); - } catch (e) { + } catch (e: any) { console.error("%s: error: %s", path.basename(process.argv[1]), e.message); process.exit(1); } @@ -130,7 +130,7 @@ ${help}`); try { const opts = dashdash.parse({ options }); - } catch (e) { + } catch (e: any) { console.error("%s: error: %s", path.basename(process.argv[1]), e.message); process.exit(1); } @@ -169,7 +169,7 @@ ${help}`); const parser = dashdash.createParser({ options }); try { const opts = parser.parse(process.argv); - } catch (e) { + } catch (e: any) { console.error("%s: error: %s", path.basename(process.argv[1]), e.message); process.exit(1); } diff --git a/types/deep-freeze/deep-freeze-tests.ts b/types/deep-freeze/deep-freeze-tests.ts index 654be3bcf5b203..4788198006a03d 100644 --- a/types/deep-freeze/deep-freeze-tests.ts +++ b/types/deep-freeze/deep-freeze-tests.ts @@ -1,7 +1,7 @@ import df = require("deep-freeze"); class Foo { - foo: string; + foo!: string; } const foo = df(new Foo()); const items = df([{ id: 0, name: "first" }]); diff --git a/types/director/director-tests.ts b/types/director/director-tests.ts index 8a8b27157f40d8..09f9e58e2fe3c9 100644 --- a/types/director/director-tests.ts +++ b/types/director/director-tests.ts @@ -216,7 +216,7 @@ httpRouter.attach(function() { // -------------------------------- class MyTtyClass { - some_unique_field_name: boolean; + some_unique_field_name!: boolean; } let cliRouter: director.cli.Router = new director.cli.Router(); diff --git a/types/dom-chromium-ai/index.d.ts b/types/dom-chromium-ai/index.d.ts index c539ae728ff60e..434453a91773f5 100644 --- a/types/dom-chromium-ai/index.d.ts +++ b/types/dom-chromium-ai/index.d.ts @@ -441,7 +441,7 @@ interface ProofreadCorrection { startIndex: number; endIndex: number; correction: string; - type?: CorrectionType; + types?: CorrectionType[]; explanation?: string; } diff --git a/types/ee-first/ee-first-tests.ts b/types/ee-first/ee-first-tests.ts index 834445d1bbe393..c889541108bdb7 100644 --- a/types/ee-first/ee-first-tests.ts +++ b/types/ee-first/ee-first-tests.ts @@ -2,11 +2,11 @@ import first = require("ee-first"); import { EventEmitter } from "events"; class Foo extends EventEmitter { - foo: "foo"; + foo!: "foo"; } class Bar extends EventEmitter { - bar: "bar"; + bar!: "bar"; } const ee1 = new Foo(); diff --git a/types/ember-data/test/transform.ts b/types/ember-data/test/transform.ts index 86c68920203227..eedc3e83564342 100644 --- a/types/ember-data/test/transform.ts +++ b/types/ember-data/test/transform.ts @@ -3,8 +3,8 @@ import Ember from "ember"; import DS from "ember-data"; export class Point extends Ember.Object { - x: number; - y: number; + x!: number; + y!: number; } class PointTransform extends DS.Transform { diff --git a/types/ember-data/v2/test/transform.ts b/types/ember-data/v2/test/transform.ts index 50a39b9a100c29..5bdb022ec8682d 100644 --- a/types/ember-data/v2/test/transform.ts +++ b/types/ember-data/v2/test/transform.ts @@ -2,8 +2,8 @@ import Ember from "ember"; import DS from "ember-data"; class Point extends Ember.Object { - x: number; - y: number; + x!: number; + y!: number; } const PointTransform = DS.Transform.extend({ diff --git a/types/ember-data/v3/test/transform.ts b/types/ember-data/v3/test/transform.ts index 41d564e750ed0b..5bdb69f630ddef 100644 --- a/types/ember-data/v3/test/transform.ts +++ b/types/ember-data/v3/test/transform.ts @@ -2,8 +2,8 @@ import Ember from "ember"; import DS from "ember-data"; export class Point extends Ember.Object { - x: number; - y: number; + x!: number; + y!: number; } class PointTransform extends DS.Transform { diff --git a/types/ember-data__model/test/model.ts b/types/ember-data__model/test/model.ts index 5cf5a686df5cd9..9c39294e3a0cae 100644 --- a/types/ember-data__model/test/model.ts +++ b/types/ember-data__model/test/model.ts @@ -40,19 +40,19 @@ const User = Model.extend({ class Human extends Model { @attr - age: number; + age!: number; @belongsTo("human") - mother: AsyncBelongsTo; + mother!: AsyncBelongsTo; @belongsTo("human", { async: false }) - motherSync: Human; + motherSync!: Human; @belongsTo("human") - father: AsyncBelongsTo; + father!: AsyncBelongsTo; @belongsTo("human", { async: false }) - fatherSync: Human | null; + fatherSync!: Human | null; @hasMany("person") - children: AsyncHasMany; + children!: AsyncHasMany; @hasMany("person", { async: false }) - childrenSync: SyncHasMany; + childrenSync!: SyncHasMany; } const user = User.create({ username: "dwickern" }); diff --git a/types/ember-data__model/v3/test/model.ts b/types/ember-data__model/v3/test/model.ts index 5cf5a686df5cd9..9c39294e3a0cae 100644 --- a/types/ember-data__model/v3/test/model.ts +++ b/types/ember-data__model/v3/test/model.ts @@ -40,19 +40,19 @@ const User = Model.extend({ class Human extends Model { @attr - age: number; + age!: number; @belongsTo("human") - mother: AsyncBelongsTo; + mother!: AsyncBelongsTo; @belongsTo("human", { async: false }) - motherSync: Human; + motherSync!: Human; @belongsTo("human") - father: AsyncBelongsTo; + father!: AsyncBelongsTo; @belongsTo("human", { async: false }) - fatherSync: Human | null; + fatherSync!: Human | null; @hasMany("person") - children: AsyncHasMany; + children!: AsyncHasMany; @hasMany("person", { async: false }) - childrenSync: SyncHasMany; + childrenSync!: SyncHasMany; } const user = User.create({ username: "dwickern" }); diff --git a/types/ember/v2/test/array-ext.ts b/types/ember/v2/test/array-ext.ts index 8b6d4cb79122fd..332dccf8753b44 100755 --- a/types/ember/v2/test/array-ext.ts +++ b/types/ember/v2/test/array-ext.ts @@ -6,7 +6,7 @@ declare global { } class Person extends Ember.Object { - name: string; + name!: string; } const person = Person.create({ name: "Joe" }); diff --git a/types/ember/v2/test/create.ts b/types/ember/v2/test/create.ts index d29e9e0c8e4479..6564371df42556 100755 --- a/types/ember/v2/test/create.ts +++ b/types/ember/v2/test/create.ts @@ -17,9 +17,9 @@ export class Person extends Ember.Object.extend({ return [this.firstName + this.lastName].join(" "); }), }) { - firstName: string; - lastName: string; - age: number; + firstName!: string; + lastName!: string; + age!: number; } const p = new Person(); assertType(p.firstName); diff --git a/types/ember/v2/test/detect-instance.ts b/types/ember/v2/test/detect-instance.ts index bd419b4621b0ae..0a106ddde3f616 100755 --- a/types/ember/v2/test/detect-instance.ts +++ b/types/ember/v2/test/detect-instance.ts @@ -6,7 +6,7 @@ const ExtendClass = Ember.Object.extend({ }); class ES6Class extends Ember.Object { - bar: string; + bar!: string; } let testObject: any = null; diff --git a/types/ember/v2/test/detect.ts b/types/ember/v2/test/detect.ts index 6221cbfcd9ccc6..5d02ed83844c74 100755 --- a/types/ember/v2/test/detect.ts +++ b/types/ember/v2/test/detect.ts @@ -6,7 +6,7 @@ const ExtendClass = Ember.Object.extend({ }); class ES6Class extends Ember.Object { - bar: string; + bar!: string; } let TestClass = Ember.Object; diff --git a/types/ember/v2/test/extend.ts b/types/ember/v2/test/extend.ts index b07f6db68e08d3..b2f7121e55fa5f 100755 --- a/types/ember/v2/test/extend.ts +++ b/types/ember/v2/test/extend.ts @@ -23,8 +23,8 @@ assertType(person.getFullName()); assertType(person.extra); class ES6Person extends Ember.Object { - firstName: string; - lastName: string; + firstName!: string; + lastName!: string; get fullName() { return `${this.firstName} ${this.lastName}`; diff --git a/types/ember/v2/test/helper.ts b/types/ember/v2/test/helper.ts index 1f12b5dcd0ef6a..038d487840d778 100755 --- a/types/ember/v2/test/helper.ts +++ b/types/ember/v2/test/helper.ts @@ -7,11 +7,11 @@ const FormatCurrencyHelper = Ember.Helper.helper(function(params, hash: { curren }); class User extends Ember.Object { - email: string; + email!: string; } class SessionService extends Ember.Service { - currentUser: User; + currentUser!: User; } const CurrentUserEmailHelper = Ember.Helper.extend({ diff --git a/types/ember/v2/test/inject.ts b/types/ember/v2/test/inject.ts index 400bf808b412ac..b5b55014db5763 100755 --- a/types/ember/v2/test/inject.ts +++ b/types/ember/v2/test/inject.ts @@ -1,12 +1,12 @@ import Ember from "ember"; class AuthService extends Ember.Service { - isAuthenticated: boolean; + isAuthenticated!: boolean; } class ApplicationController extends Ember.Controller { model = {}; - string: string; + string!: string; transitionToLogin() {} } diff --git a/types/ember/v2/test/observable.ts b/types/ember/v2/test/observable.ts index d6c9e1438c1a9c..903b68bb13b37b 100755 --- a/types/ember/v2/test/observable.ts +++ b/types/ember/v2/test/observable.ts @@ -5,7 +5,7 @@ class MyComponent extends Ember.Component { foo = "bar"; init() { - this._super.apply(this, arguments); + this._super.apply(this, arguments as unknown as any[]); this.addObserver("foo", this, "fooDidChange"); this.addObserver("foo", this, this.fooDidChange); Ember.addObserver(this, "foo", this, "fooDidChange"); diff --git a/types/ember/v3/test/array-ext.ts b/types/ember/v3/test/array-ext.ts index 1a1fac491fcf3e..6e78c5adb26dea 100755 --- a/types/ember/v3/test/array-ext.ts +++ b/types/ember/v3/test/array-ext.ts @@ -6,7 +6,7 @@ declare global { } class Person extends Ember.Object { - name: string; + name!: string; } const person = Person.create({ name: "Joe" }); diff --git a/types/ember/v3/test/create.ts b/types/ember/v3/test/create.ts index 2f2470eb093035..0727fd5fcf5331 100755 --- a/types/ember/v3/test/create.ts +++ b/types/ember/v3/test/create.ts @@ -32,9 +32,9 @@ export class Person extends Ember.Object.extend({ return [this.firstName + this.lastName].join(" "); }), }) { - firstName: string; - lastName: string; - age: number; + firstName!: string; + lastName!: string; + age!: number; } const p = new Person(); diff --git a/types/ember/v3/test/detect-instance.ts b/types/ember/v3/test/detect-instance.ts index 9a79053e49e596..b66797adbe37df 100755 --- a/types/ember/v3/test/detect-instance.ts +++ b/types/ember/v3/test/detect-instance.ts @@ -6,7 +6,7 @@ const ExtendClass = Ember.Object.extend({ }); class ES6Class extends Ember.Object { - bar: string; + bar!: string; } const testObject: any = null; diff --git a/types/ember/v3/test/detect.ts b/types/ember/v3/test/detect.ts index 2f4a8eaa788017..6617899984bbff 100755 --- a/types/ember/v3/test/detect.ts +++ b/types/ember/v3/test/detect.ts @@ -6,7 +6,7 @@ const ExtendClass = Ember.Object.extend({ }); class ES6Class extends Ember.Object { - bar: string; + bar!: string; } const TestClass = Ember.Object; diff --git a/types/ember/v3/test/extend.ts b/types/ember/v3/test/extend.ts index b07f6db68e08d3..b2f7121e55fa5f 100755 --- a/types/ember/v3/test/extend.ts +++ b/types/ember/v3/test/extend.ts @@ -23,8 +23,8 @@ assertType(person.getFullName()); assertType(person.extra); class ES6Person extends Ember.Object { - firstName: string; - lastName: string; + firstName!: string; + lastName!: string; get fullName() { return `${this.firstName} ${this.lastName}`; diff --git a/types/ember/v3/test/helper.ts b/types/ember/v3/test/helper.ts index e34c68d83ba8dc..7e09afe321f56e 100755 --- a/types/ember/v3/test/helper.ts +++ b/types/ember/v3/test/helper.ts @@ -7,11 +7,11 @@ const FormatCurrencyHelper = Ember.Helper.helper((params: [number], hash: { curr }); class User extends Ember.Object { - email: string; + email!: string; } class SessionService extends Ember.Service { - currentUser: User; + currentUser!: User; } declare module "@ember/service" { diff --git a/types/ember/v3/test/inject.ts b/types/ember/v3/test/inject.ts index 52a56661e1a44f..2ff215d08f1db1 100755 --- a/types/ember/v3/test/inject.ts +++ b/types/ember/v3/test/inject.ts @@ -1,12 +1,12 @@ import Ember from "ember"; class AuthService extends Ember.Service { - isAuthenticated: boolean; + isAuthenticated!: boolean; } class ApplicationController extends Ember.Controller { model = {}; - string: string; + string!: string; transitionToLogin() {} } diff --git a/types/ember/v3/test/observable.ts b/types/ember/v3/test/observable.ts index f9c84483c92837..b244b9a7b6c36a 100755 --- a/types/ember/v3/test/observable.ts +++ b/types/ember/v3/test/observable.ts @@ -5,7 +5,7 @@ class MyComponent extends Ember.Component { foo = "bar"; init() { - this._super.apply(this, arguments); + this._super.apply(this, arguments as unknown as any[]); this.addObserver("foo", this, "fooDidChange"); this.addObserver("foo", this, this.fooDidChange); Ember.addObserver(this, "foo", this, "fooDidChange"); diff --git a/types/ember/v3/test/techniques/properties-from-this.ts b/types/ember/v3/test/techniques/properties-from-this.ts index 84d21f0416ff1c..aabd27d60acaee 100644 --- a/types/ember/v3/test/techniques/properties-from-this.ts +++ b/types/ember/v3/test/techniques/properties-from-this.ts @@ -5,8 +5,8 @@ */ class BoxedProperty { - __getType: Get; - __setType: Set; + __getType!: Get; + __setType!: Set; } type UnboxGetProperty = T extends BoxedProperty ? V : T; diff --git a/types/ember__array/v3/test/array-ext.ts b/types/ember__array/v3/test/array-ext.ts index b73fc2cfa4d470..b743c9954e1efd 100755 --- a/types/ember__array/v3/test/array-ext.ts +++ b/types/ember__array/v3/test/array-ext.ts @@ -7,7 +7,7 @@ declare global { } class Person extends EmberObject { - name: string; + name!: string; } const person = Person.create({ name: "Joe" }); diff --git a/types/ember__controller/v3/test/octane.ts b/types/ember__controller/v3/test/octane.ts index 2fb668e4f9f295..035f085e5704ec 100644 --- a/types/ember__controller/v3/test/octane.ts +++ b/types/ember__controller/v3/test/octane.ts @@ -3,11 +3,11 @@ import Controller, { inject } from "@ember/controller"; class FirstController extends Controller { foo = "bar"; @inject - second: InstanceType; + second!: InstanceType; @inject() - otherSecond: InstanceType; + otherSecond!: InstanceType; @inject("second") - moreSecond: InstanceType; + moreSecond!: InstanceType; queryParams = [ "category", diff --git a/types/ember__object/v3/test/compat.ts b/types/ember__object/v3/test/compat.ts index c7e05c1ea29f3e..2c55a4cb081145 100644 --- a/types/ember__object/v3/test/compat.ts +++ b/types/ember__object/v3/test/compat.ts @@ -2,8 +2,8 @@ import { dependentKeyCompat } from "@ember/object/compat"; // Example (without irrelevant details) from https://api.emberjs.com/ember/3.18/functions/@ember%2Fobject%2Fcompat/dependentKeyCompat class Person { - firstName: string; - lastName: string; + firstName!: string; + lastName!: string; @dependentKeyCompat get fullName() { diff --git a/types/ember__object/v3/test/create.ts b/types/ember__object/v3/test/create.ts index e833d78414a345..f51acca6f9bc7e 100644 --- a/types/ember__object/v3/test/create.ts +++ b/types/ember__object/v3/test/create.ts @@ -31,9 +31,9 @@ export class Person extends EmberObject { fullName = computed("firstName", "lastName", function() { return [this.firstName + this.lastName].join(" "); }); - firstName: string; - lastName: string; - age: number; + firstName!: string; + lastName!: string; + age!: number; } const p = new Person(); diff --git a/types/ember__object/v3/test/detect-instance.ts b/types/ember__object/v3/test/detect-instance.ts index 4fb0c8719e997d..abcb0d1c70b312 100755 --- a/types/ember__object/v3/test/detect-instance.ts +++ b/types/ember__object/v3/test/detect-instance.ts @@ -6,7 +6,7 @@ const ExtendClass = EmberObject.extend({ }); class ES6Class extends EmberObject { - bar: string; + bar!: string; } const testObject: any = null; diff --git a/types/ember__object/v3/test/detect.ts b/types/ember__object/v3/test/detect.ts index b38ea4b0a16e08..1f219844cd4d48 100755 --- a/types/ember__object/v3/test/detect.ts +++ b/types/ember__object/v3/test/detect.ts @@ -6,7 +6,7 @@ const ExtendClass = EmberObject.extend({ }); class ES6Class extends EmberObject { - bar: string; + bar!: string; } const TestClass = EmberObject; diff --git a/types/ember__object/v3/test/extend.ts b/types/ember__object/v3/test/extend.ts index 77cd9a4592f0ad..9434d90aff1cf4 100644 --- a/types/ember__object/v3/test/extend.ts +++ b/types/ember__object/v3/test/extend.ts @@ -23,8 +23,8 @@ assertType(person.getFullName()); assertType(person.extra); class ES6Person extends EmberObject { - firstName: string; - lastName: string; + firstName!: string; + lastName!: string; get fullName() { return `${this.firstName} ${this.lastName}`; diff --git a/types/ember__object/v3/test/observable.ts b/types/ember__object/v3/test/observable.ts index c6e81b87347691..500396a6a266e4 100644 --- a/types/ember__object/v3/test/observable.ts +++ b/types/ember__object/v3/test/observable.ts @@ -6,7 +6,7 @@ class MyComponent extends EmberObject { foo = "bar"; init() { - this._super.apply(this, arguments); + this._super.apply(this, arguments as unknown as any[]); this.addObserver("foo", this, "fooDidChange"); this.addObserver("foo", this, this.fooDidChange); addObserver(this, "foo", this, "fooDidChange"); diff --git a/types/ember__object/v3/test/octane.ts b/types/ember__object/v3/test/octane.ts index 98d6836ca338ca..fecdc2571587ca 100644 --- a/types/ember__object/v3/test/octane.ts +++ b/types/ember__object/v3/test/octane.ts @@ -42,12 +42,12 @@ function customMacro(message: string) { // Native class syntax class Foo extends EmberObject { - firstName: string; - lastName: string; + firstName!: string; + lastName!: string; // @ts-expect-error @action - bar: string; + bar!: string; @computed("firstName", "lastName") get fullName() { @@ -56,15 +56,15 @@ class Foo extends EmberObject { // @ts-expect-error @computed("firstName", "lastName") - badFullName: string; + badFullName!: string; @computed("fullName", function(this: Foo) { return this.fullName.toUpperCase(); }) - bigFullName: string; + bigFullName!: string; @customMacro("hi") - hiTwice: string[]; + hiTwice!: string[]; @action foo() {} @@ -73,383 +73,383 @@ class Foo extends EmberObject { // Computed property macros class Bar extends EmberObject { - firstName: string; - last: string; + firstName!: string; + last!: string; - values: number[]; + values!: number[]; // @ts-expect-error @alias - aliasTest0: string; + aliasTest0!: string; // @ts-expect-error @alias() - aliasTest1: string; + aliasTest1!: string; @alias("firstName") - aliasTest2: string; + aliasTest2!: string; // @ts-expect-error @and - andTest0: boolean; + andTest0!: boolean; @and() - andTest1: boolean; + andTest1!: boolean; @and("firstName") - andTest2: boolean; + andTest2!: boolean; @and("firstName", "lastName") - andTest3: boolean; + andTest3!: boolean; // @ts-expect-error @bool - boolTest0: boolean; + boolTest0!: boolean; // @ts-expect-error @bool() - boolTest1: boolean; + boolTest1!: boolean; @bool("firstName") - boolTest2: boolean; + boolTest2!: boolean; // @ts-expect-error @collect - collectTest0: any; + collectTest0!: any; @collect() - collectTest1: any; + collectTest1!: any; @collect("firstName") - collectTest2: any; + collectTest2!: any; // @ts-expect-error @deprecatingAlias - deprecatingAliasTest0: string; + deprecatingAliasTest0!: string; // @ts-expect-error @deprecatingAlias() - deprecatingAliasTest1: string; + deprecatingAliasTest1!: string; @deprecatingAlias("firstName") - deprecatingAliasTest2: string; + deprecatingAliasTest2!: string; // @ts-expect-error @empty - emptyTest0: boolean; + emptyTest0!: boolean; // @ts-expect-error @empty() - emptyTest1: boolean; + emptyTest1!: boolean; @empty("firstName") - emptyTest2: boolean; + emptyTest2!: boolean; // @ts-expect-error @equal - equalTest0: boolean; + equalTest0!: boolean; // @ts-expect-error @equal() - equalTest1: boolean; + equalTest1!: boolean; // @ts-expect-error @equal("firstName") - equalTest2: boolean; + equalTest2!: boolean; @equal("firstName", "lastName") - equalTest3: boolean; + equalTest3!: boolean; // @ts-expect-error @filter - filterTest1: string[]; + filterTest1!: string[]; // @ts-expect-error @filter() - filterTest2: string[]; + filterTest2!: string[]; // @ts-expect-error @filter("firstName") - filterTest3: string[]; + filterTest3!: string[]; @filter("firstName", x => x) - filterTest4: string[]; + filterTest4!: string[]; // @ts-expect-error @filter("firstName", "secondName", x => x) - filterTest5: string[]; + filterTest5!: string[]; @filter("firstName", ["secondName"], x => x) - filterTest6: string[]; + filterTest6!: string[]; // @ts-expect-error @filterBy - filterByTest1: any[]; + filterByTest1!: any[]; // @ts-expect-error @filterBy() - filterByTest2: any[]; + filterByTest2!: any[]; // @ts-expect-error @filterBy("firstName") - filterByTest3: any[]; + filterByTest3!: any[]; @filterBy("firstName", "id") - filterByTest4: any[]; + filterByTest4!: any[]; // @ts-expect-error @gt - gtTest1: boolean; + gtTest1!: boolean; // @ts-expect-error @gt() - gtTest2: boolean; + gtTest2!: boolean; // @ts-expect-error @gt("firstName") - gtTest3: boolean; + gtTest3!: boolean; @gt("firstName", 3) - gtTest4: boolean; + gtTest4!: boolean; // @ts-expect-error @gte - gteTest1: boolean; + gteTest1!: boolean; // @ts-expect-error @gte() - gteTest2: boolean; + gteTest2!: boolean; // @ts-expect-error @gte("firstName") - gteTest3: boolean; + gteTest3!: boolean; @gte("firstName", 3) - gteTest4: boolean; + gteTest4!: boolean; // @ts-expect-error @intersect - intersectTest1: any; + intersectTest1!: any; @intersect() - intersectTest2: any; + intersectTest2!: any; @intersect("firstName") - intersectTest3: any; + intersectTest3!: any; @intersect("firstName", "lastName") - intersectTest4: any; + intersectTest4!: any; // @ts-expect-error @lt - ltTest1: boolean; + ltTest1!: boolean; // @ts-expect-error @lt() - ltTest2: boolean; + ltTest2!: boolean; // @ts-expect-error @lt("firstName") - ltTest3: boolean; + ltTest3!: boolean; @lt("firstName", 3) - ltTest4: boolean; + ltTest4!: boolean; // @ts-expect-error @lte - lteTest1: boolean; + lteTest1!: boolean; // @ts-expect-error @lte() - lteTest2: boolean; + lteTest2!: boolean; // @ts-expect-error @lte("firstName") - lteTest3: boolean; + lteTest3!: boolean; @lte("firstName", 3) - lteTest4: boolean; + lteTest4!: boolean; // @ts-expect-error @map - mapTest1: string[]; + mapTest1!: string[]; // @ts-expect-error @map() - mapTest2: string[]; + mapTest2!: string[]; // @ts-expect-error @map("firstName") - mapTest3: string[]; + mapTest3!: string[]; @map("firstName", x => x) - mapTest4: string[]; + mapTest4!: string[]; // @ts-expect-error @mapBy - mapByTest1: any[]; + mapByTest1!: any[]; // @ts-expect-error @mapBy() - mapByTest2: any[]; + mapByTest2!: any[]; // @ts-expect-error @mapBy("firstName") - mapByTest3: any[]; + mapByTest3!: any[]; @mapBy("firstName", "id") - mapByTest4: any[]; + mapByTest4!: any[]; // @ts-expect-error @match - matchTest1: boolean; + matchTest1!: boolean; // @ts-expect-error @match() - matchTest2: boolean; + matchTest2!: boolean; // @ts-expect-error @match("firstName") - matchTest3: boolean; + matchTest3!: boolean; // @ts-expect-error @match("firstName", "abc") - matchTest4: boolean; + matchTest4!: boolean; @match("firstName", /\s+/) - matchTest5: boolean; + matchTest5!: boolean; // @ts-expect-error @max - maxTest1: number; + maxTest1!: number; // @ts-expect-error @max() - maxTest2: number; + maxTest2!: number; @max("values") - maxTest3: number; + maxTest3!: number; // @ts-expect-error @max("values", "a") - maxTest4: number; + maxTest4!: number; // @ts-expect-error @min - minTest1: number; + minTest1!: number; // @ts-expect-error @min() - minTest2: number; + minTest2!: number; @min("values") - minTest3: number; + minTest3!: number; // @ts-expect-error @min("values", "a") - minTest4: number; + minTest4!: number; // @ts-expect-error @none - noneTest1: number; + noneTest1!: number; // @ts-expect-error @none() - noneTest2: number; + noneTest2!: number; @none("values") - noneTest3: number; + noneTest3!: number; // @ts-expect-error @none("values", "a") - noneTest4: number; + noneTest4!: number; // @ts-expect-error @not - notTest1: number; + notTest1!: number; // @ts-expect-error @not() - notTest2: number; + notTest2!: number; @not("values") - notTest3: number; + notTest3!: number; // @ts-expect-error @not("values", "a") - notTest4: number; + notTest4!: number; // @ts-expect-error @notEmpty - notEmptyTest1: boolean; + notEmptyTest1!: boolean; // @ts-expect-error @notEmpty() - notEmptyTest2: boolean; + notEmptyTest2!: boolean; @notEmpty("firstName") - notEmptyTest3: boolean; + notEmptyTest3!: boolean; // @ts-expect-error @notEmpty("firstName", "a") - notEmptyTest4: boolean; + notEmptyTest4!: boolean; // @ts-expect-error @oneWay - oneWayTest1: boolean; + oneWayTest1!: boolean; // @ts-expect-error @oneWay() - oneWayTest2: boolean; + oneWayTest2!: boolean; @oneWay("firstName") - oneWayTest3: boolean; + oneWayTest3!: boolean; // @ts-expect-error @oneWay("firstName", "b") - oneWayTest4: boolean; + oneWayTest4!: boolean; // @ts-expect-error @or - orTest1: boolean; + orTest1!: boolean; @or() - orTest2: boolean; + orTest2!: boolean; @or("firstName") - orTest3: boolean; + orTest3!: boolean; @or("firstName", "lastName") - orTest4: boolean; + orTest4!: boolean; // @ts-expect-error @readOnly - readOnlyTest1: boolean; + readOnlyTest1!: boolean; // @ts-expect-error @readOnly() - readOnlyTest2: boolean; + readOnlyTest2!: boolean; @readOnly("firstName") - readOnlyTest3: boolean; + readOnlyTest3!: boolean; // @ts-expect-error @reads - readsTest1: boolean; + readsTest1!: boolean; // @ts-expect-error @reads() - readsTest2: boolean; + readsTest2!: boolean; @reads("firstName") - readsTest3: boolean; + readsTest3!: boolean; // @ts-expect-error @reads("firstName", "a") - readsTest4: boolean; + readsTest4!: boolean; // @ts-expect-error @setDiff - setDiffTest1: number; + setDiffTest1!: number; // @ts-expect-error @setDiff() - setDiffTest2: number; + setDiffTest2!: number; // @ts-expect-error @setDiff("values") - setDiffTest3: number; + setDiffTest3!: number; @setDiff("values", "otherThing") - setDiffTest4: number; + setDiffTest4!: number; // @ts-expect-error @setDiff("values", "otherThing", "a") - setDiffTest5: number; + setDiffTest5!: number; // @ts-expect-error @sort - sortTest1: number; + sortTest1!: number; // @ts-expect-error @sort() - sortTest2: number; + sortTest2!: number; // @ts-expect-error @sort("values") - sortTest3: number; + sortTest3!: number; @sort("values", "id") - sortTest4: number; + sortTest4!: number; // @ts-expect-error @sort("values", "id", "a") - sortTest5: number; + sortTest5!: number; @sort("values", (a, b) => a - b) - sortTest6: number; + sortTest6!: number; @sort("values", ["id"], (a, b) => a - b) - sortTest7: number; + sortTest7!: number; // @ts-expect-error @sort("values", "id", (a, b) => a - b) - sortTest8: number; + sortTest8!: number; // @ts-expect-error @sort(["id"], (a, b) => a - b) - sortTest9: number; + sortTest9!: number; // @ts-expect-error @sum - sumTest1: number; + sumTest1!: number; // @ts-expect-error @sum() - sumTest2: number; + sumTest2!: number; @sum("values") - sumTest3: number; + sumTest3!: number; // @ts-expect-error @union - unionTest1: any; + unionTest1!: any; @union() - unionTest2: any; + unionTest2!: any; @union("firstName") - unionTest3: any; + unionTest3!: any; @union("firstName", "lastName") - unionTest4: any; + unionTest4!: any; // @ts-expect-error @uniq - uniqTest1: number; + uniqTest1!: number; // @ts-expect-error @uniq() - uniqTest2: number; + uniqTest2!: number; @uniq("values") - uniqTest3: number; + uniqTest3!: number; // @ts-expect-error @uniqBy - uniqByTest1: number; + uniqByTest1!: number; // @ts-expect-error @uniqBy() - uniqByTest2: number; + uniqByTest2!: number; // @ts-expect-error @uniqBy("values") - uniqByTest3: number; + uniqByTest3!: number; @uniqBy("values", "id") - uniqByTest4: number; + uniqByTest4!: number; } diff --git a/types/ember__service/v3/test/octane.ts b/types/ember__service/v3/test/octane.ts index cf548ec9f3b7e9..e9b7ef592c76bb 100644 --- a/types/ember__service/v3/test/octane.ts +++ b/types/ember__service/v3/test/octane.ts @@ -23,9 +23,9 @@ declare module "@ember/service" { class Foo extends EmberObject { @inject - foo: FirstSvc; + foo!: FirstSvc; @inject("first") - baz: FirstSvc; + baz!: FirstSvc; @inject() - bar: FirstSvc; + bar!: FirstSvc; } diff --git a/types/emscripten/emscripten-tests.ts b/types/emscripten/emscripten-tests.ts index 26df4b5374c7c9..81854c3e1c1356 100644 --- a/types/emscripten/emscripten-tests.ts +++ b/types/emscripten/emscripten-tests.ts @@ -24,8 +24,8 @@ function ModuleTest(): void { Module.onAbort = (what) => console.log("abort"); Module.onRuntimeInitialized = () => console.log("init"); - const package: ArrayBuffer = Module.getPreloadedPackage("package-name", 100); - const exports: WebAssembly.Exports | undefined = Module.instantiateWasm( + const pkg: ArrayBuffer = Module.getPreloadedPackage("package-name", 100); + const wasmExports: WebAssembly.Exports | undefined = Module.instantiateWasm( { a: { n: function __syscall_chmod() {} } }, (module: WebAssembly.Instance) => {}, ); diff --git a/types/es-get-iterator/es-get-iterator-tests.ts b/types/es-get-iterator/es-get-iterator-tests.ts index d29b7d630335cc..13519e709cadb3 100644 --- a/types/es-get-iterator/es-get-iterator-tests.ts +++ b/types/es-get-iterator/es-get-iterator-tests.ts @@ -1,21 +1,21 @@ import getIterator = require("es-get-iterator"); -// $ExpectType Iterator || Iterator +// $ExpectType Iterator || Iterator || Iterator getIterator("foo"); -// $ExpectType Iterator || Iterator +// $ExpectType Iterator || Iterator || Iterator getIterator([]); -// $ExpectType Iterator || Iterator +// $ExpectType Iterator || Iterator || Iterator getIterator([0, 1, 2, 3, 4]); -// $ExpectType Iterator || Iterator +// $ExpectType Iterator || Iterator || Iterator getIterator([undefined, true, "bar", 0]); -// $ExpectType Iterator<[symbol, unknown], any, undefined> || Iterator<[symbol, unknown], any, unknown> +// $ExpectType Iterator<[symbol, unknown], any, undefined> || Iterator<[symbol, unknown], any, unknown> || Iterator<[symbol, unknown], undefined, unknown> getIterator(new Map()); -// $ExpectType Iterator || Iterator +// $ExpectType Iterator || Iterator || Iterator getIterator(new Set()); // $ExpectType Iterator<"foo" | "bar", void, unknown> || Iterator<"foo" | "bar", void, any> @@ -32,15 +32,15 @@ getIterator((function*() { })()); declare const ARGUMENTS: IArguments; -// $ExpectType Iterator || Iterator +// $ExpectType Iterator || Iterator || Iterator getIterator(ARGUMENTS); declare const ITERABLE_UNION: number[] | Set; -// $ExpectType Iterator | Iterator || Iterator | Iterator +// $ExpectType Iterator | Iterator || Iterator | Iterator || Iterator | Iterator getIterator(ITERABLE_UNION); declare const ITERABLE_OR_OTHERS_UNION: Map | ArrayBuffer; -// $ExpectType Iterator<[Error, DataView], any, undefined> | undefined || Iterator<[Error, DataView], any, unknown> | undefined || Iterator<[Error, DataView], any, unknown> | undefined +// $ExpectType Iterator<[Error, DataView], any, undefined> | undefined || Iterator<[Error, DataView], any, unknown> | undefined || Iterator<[Error, DataView], any, unknown> | undefined || Iterator<[Error, DataView], undefined, unknown> | undefined getIterator(ITERABLE_OR_OTHERS_UNION); declare const UNKNOWN: unknown; diff --git a/types/event-kit/event-kit-tests.ts b/types/event-kit/event-kit-tests.ts index bc23277e185e87..f5b80de0c75444 100644 --- a/types/event-kit/event-kit-tests.ts +++ b/types/event-kit/event-kit-tests.ts @@ -8,7 +8,7 @@ declare let emitter: Emitter; // NPM Usage Tests ============================================================ class User { private readonly emitter: Emitter; - name: string; + name!: string; constructor() { this.emitter = new Emitter(); diff --git a/types/event-stream/event-stream-tests.ts b/types/event-stream/event-stream-tests.ts index 2e9ac6b745d8cc..aa7796c42da6ed 100644 --- a/types/event-stream/event-stream-tests.ts +++ b/types/event-stream/event-stream-tests.ts @@ -2,10 +2,11 @@ import gulp = require("gulp"); import * as es from "event-stream"; gulp.task("es:concat", () => { - var streams = gulp.src(["*"]) - .pipe(gulp.dest("build")); + const streams: es.MapStream[] = [ + gulp.src(["*"]).pipe(gulp.dest("build")) as unknown as es.MapStream, + ]; - return es.concat.apply(null, streams); + return es.concat(streams); }); gulp.task("es:readArray ", () => { diff --git a/types/expectations/expectations-tests.ts b/types/expectations/expectations-tests.ts index dd6a2de00dee00..f88e746d4ac626 100644 --- a/types/expectations/expectations-tests.ts +++ b/types/expectations/expectations-tests.ts @@ -18,7 +18,7 @@ describe("expect", () => { it("can expect false not to be true", () => { try { expect(false).toEqual(true); - } catch (err) { + } catch (err: any) { if (err.message !== "expected false to equal true") { throw new Error("Expected error message is not correct: " + err.message); } @@ -42,7 +42,7 @@ describe("expect", () => { it("Can expect undefined to equal an object correctly", () => { try { expect(undefined).toEqual("Not undefined"); - } catch (err) { + } catch (err: any) { if (err.message !== "expected undefined to equal \"Not undefined\"") { throw new Error("Expected error message is not correct: " + err.message); } @@ -57,7 +57,7 @@ describe("expect", () => { it("can expect true not to be true", () => { try { expect(true).toNotEqual(true); - } catch (err) { + } catch (err: any) { if (err.message !== "expected true not to equal true") { throw new Error("Expected error message is not correct: " + err.message); } @@ -74,7 +74,7 @@ describe("expect", () => { it("does not expect an object to be a different", () => { try { expect(obj1).toBe(obj2); - } catch (err) { + } catch (err: any) { if (err.message !== "expected {\"abc\": 123} to equal {\"abc\": 123}") { throw new Error("Expected error message is not correct: " + err.message); } @@ -89,7 +89,7 @@ describe("expect", () => { it("can expect string to not match", () => { try { expect("abc").toMatch(/d/); - } catch (err) { + } catch (err: any) { if (err.message !== "expected \"abc\" to match /d/") { throw new Error("Expected error message is not correct: " + err.message); } @@ -104,7 +104,7 @@ describe("expect", () => { it("can expect toBeTruthy when falsey", () => { try { expect("").toBeTruthy(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected \"\" to be truthy") { throw new Error("Expected error message is not correct: " + err.message); } @@ -119,7 +119,7 @@ describe("expect", () => { it("can expect array of numbers to contain number (failing)", () => { try { expect([1, 2, 3, 4]).toContain(5); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [1, 2, 3, 4] to contain 5") { throw new Error("Expected error message is not correct: " + err.message); } @@ -141,7 +141,7 @@ describe("expect", () => { { a: 3 }, { a: 4 }, ]).toContain({ a: 5 }); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [{\"a\": 1}, {\"a\": 2}, {\"a\": 3}, {\"a\": 4}] to contain {\"a\": 5}") { throw new Error("Expected error message is not correct: " + err.message); } @@ -156,7 +156,7 @@ describe("expect", () => { it("can expect toBeFalsy when truthy", () => { try { expect("abc").toBeFalsy(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected \"abc\" to be falsey") { throw new Error("Expected error message is not correct: " + err.message); } @@ -171,7 +171,7 @@ describe("expect", () => { it("can expect 0 toBeGreaterThan 1 throws", () => { try { expect(0).toBeGreaterThan(1); - } catch (err) { + } catch (err: any) { if (err.message !== "expected 0 to be greater than 1") { throw new Error("Expected error message is not correct: " + err.message); } @@ -186,7 +186,7 @@ describe("expect", () => { it("can expect 1 toBeLessThan 0 throws", () => { try { expect(1).toBeLessThan(0); - } catch (err) { + } catch (err: any) { if (err.message !== "expected 1 to be less than 0") { throw new Error("Expected error message is not correct: " + err.message); } @@ -201,7 +201,7 @@ describe("expect", () => { it("throws when expects undefined values toBeDefined", () => { try { expect(undefined).toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected undefined to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -216,7 +216,7 @@ describe("expect", () => { it("throws when expects defined values toBeUndefined", () => { try { expect({}).toBeUndefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected {} to be undefined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -237,7 +237,7 @@ describe("expect", () => { expect(() => { // All OK }).toThrow(); - } catch (err) { + } catch (err: any) { error = err; } @@ -253,7 +253,7 @@ describe("expect", () => { try { expect("bob").toThrow(); - } catch (err) { + } catch (err: any) { error = err; } @@ -273,7 +273,7 @@ describe("expect", () => { it("throws when expects non-null values toBeNull", () => { try { expect("abc").toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected \"abc\" to be null") { throw new Error("Expected error message is not correct: " + err.message); } @@ -291,7 +291,7 @@ describe("expect", () => { it("can generate correct message for objects", () => { try { expect({}).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected {} not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -300,7 +300,7 @@ describe("expect", () => { it("can generate correct message for arrays", () => { try { expect([]).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [] not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -309,7 +309,7 @@ describe("expect", () => { it("can generate correct message for arrays of values", () => { try { expect([1, { abc: "def" }]).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [1, {\"abc\": \"def\"}] not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -318,7 +318,7 @@ describe("expect", () => { it("can generate correct message for nested arrays of values", () => { try { expect([1, [2]]).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [1, [2]] not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -333,7 +333,7 @@ describe("expect", () => { }; try { expect(new ( Obj)()).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [testing] not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -342,7 +342,7 @@ describe("expect", () => { it("can generate correct message for Errors", () => { try { expect(new Error("text")).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [Error: text] not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -353,7 +353,7 @@ describe("expect", () => { var obj: any = { abc: "def" }; obj.obj = obj; expect(obj).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if ( err.message !== "expected {\"abc\": \"def\", \"obj\": {\"abc\": \"def\", \"obj\": [Circular]}} not to be defined" @@ -376,7 +376,7 @@ describe("expect", () => { nested.e = obj; try { expect(obj).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if ( err.message !== "expected {\"a\": {\"b\": {\"c\": {\"d\": {\"e\": [object Object]}}}}} not to be defined" @@ -399,7 +399,7 @@ describe("expect", () => { nested.e = [obj]; try { expect(obj).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if ( err.message !== "expected {\"a\": {\"b\": {\"c\": {\"d\": {\"e\": [[object Object]]}}}}} not to be defined" @@ -411,7 +411,7 @@ describe("expect", () => { it("can generate correct message for objects with undefined values", () => { try { expect({ a: 1, b: undefined }).toEqual({ a: 1 }); - } catch (err) { + } catch (err: any) { if (err.message !== "expected {\"a\": 1, \"b\": undefined} to equal {\"a\": 1}") { throw new Error("Expected error message is not correct: " + err.message); } @@ -421,7 +421,7 @@ describe("expect", () => { try { expect(() => { }).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected function (){} not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -431,7 +431,7 @@ describe("expect", () => { try { expect(function name() { }).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected function name(){} not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -440,7 +440,7 @@ describe("expect", () => { it("can generate correct message for Dates", () => { try { expect(new Date(2012, 0, 1)).not.toBeDefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected [Date Sun, 01 Jan 2012 00:00:00 GMT] not to be defined") { throw new Error("Expected error message is not correct: " + err.message); } @@ -452,7 +452,7 @@ describe("expect", () => { try { expect(el).toBeUndefined(); - } catch (err) { + } catch (err: any) { if (err.message !== "expected
to be undefined") { throw new Error("Expected error message is not correct: " + err.message); } diff --git a/types/eyevinn-iaf/eyevinn-iaf-tests.ts b/types/eyevinn-iaf/eyevinn-iaf-tests.ts index 5e5f1234733fc0..e242894eabcf4c 100644 --- a/types/eyevinn-iaf/eyevinn-iaf-tests.ts +++ b/types/eyevinn-iaf/eyevinn-iaf-tests.ts @@ -2,17 +2,17 @@ import { IafFileWatchModule, IafUploadModule, Logger } from "eyevinn-iaf"; import { Readable } from "stream"; class FileUploader implements IafUploadModule { - logger: Logger; - playlistName: string; - progressDelegate: (result: any) => any; - fileUploadedDelegate: (result: any, error?: any) => any; + logger!: Logger; + playlistName!: string; + progressDelegate!: (result: any) => any; + fileUploadedDelegate!: (result: any, error?: any) => any; onFileAdd(filePath: string, readStream: Readable, contentType?: string): void {} } class FileWatcher implements IafFileWatchModule { - fileInput: string; - logger: Logger; + fileInput!: string; + logger!: Logger; onAdd(callback: (filePath: string, readStream: Readable, contentType?: string) => any): void {} } diff --git a/types/fast-stable-stringify/.npmignore b/types/fast-stable-stringify/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/fast-stable-stringify/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/fast-stable-stringify/fast-stable-stringify-tests.ts b/types/fast-stable-stringify/fast-stable-stringify-tests.ts new file mode 100644 index 00000000000000..a5f452b04ae6b9 --- /dev/null +++ b/types/fast-stable-stringify/fast-stable-stringify-tests.ts @@ -0,0 +1,36 @@ +import stringify = require("fast-stable-stringify"); + +// Test with various types +const strResult: string | undefined = stringify({ a: 1, b: 2 }); +const arrResult: string | undefined = stringify([1, 2, 3]); +const numResult: string | undefined = stringify(42); +const boolResult: string | undefined = stringify(true); +const nullResult: string | undefined = stringify(null); +const undefinedResult: string | undefined = stringify(undefined); + +// Test with nested objects - keys should be sorted +const nested: string | undefined = stringify({ + c: 8, + b: [{ z: 6, y: 5, x: 4 }, 7], + a: 3, +}); + +// Test with object having toJSON method +const withToJSON: string | undefined = stringify({ + toJSON: () => ({ serialized: true }), +}); + +// Test that result can be undefined for functions +const funcResult: string | undefined = stringify(() => {}); + +// Test with string +const stringResult: string | undefined = stringify("hello"); + +// Test with Date (has toJSON) +const dateResult: string | undefined = stringify(new Date()); + +// Verify the result type allows string operations when defined +if (strResult !== undefined) { + const len: number = strResult.length; + const parsed: unknown = JSON.parse(strResult); +} diff --git a/types/fast-stable-stringify/index.d.ts b/types/fast-stable-stringify/index.d.ts new file mode 100644 index 00000000000000..f44352cd6d5d98 --- /dev/null +++ b/types/fast-stable-stringify/index.d.ts @@ -0,0 +1,18 @@ +/** + * Deterministic JSON.stringify() - outputs the same string regardless of key + * insertion order by sorting object keys alphabetically. + * + * @param val - The value to stringify + * @returns A JSON string representation, or undefined if the value cannot be stringified + * + * @example + * ```javascript + * const stringify = require('fast-stable-stringify'); + * const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 }; + * console.log(stringify(obj)); + * // Output: {"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8} + * ``` + */ +declare function stringify(val: unknown): string | undefined; + +export = stringify; diff --git a/types/fast-stable-stringify/package.json b/types/fast-stable-stringify/package.json new file mode 100644 index 00000000000000..084667cef6ac46 --- /dev/null +++ b/types/fast-stable-stringify/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/fast-stable-stringify", + "version": "1.0.9999", + "projects": [ + "https://github.com/nickyout/fast-stable-stringify" + ], + "devDependencies": { + "@types/fast-stable-stringify": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/fast-stable-stringify/tsconfig.json b/types/fast-stable-stringify/tsconfig.json new file mode 100644 index 00000000000000..03d755fdfd84e2 --- /dev/null +++ b/types/fast-stable-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", + "fast-stable-stringify-tests.ts" + ] +} diff --git a/types/fbemitter/fbemitter-tests.ts b/types/fbemitter/fbemitter-tests.ts index 084585533d7806..49821488884c6d 100644 --- a/types/fbemitter/fbemitter-tests.ts +++ b/types/fbemitter/fbemitter-tests.ts @@ -74,7 +74,7 @@ describe("EventEmitter", function tests() { assert.deepStrictEqual(Array.prototype.slice.call(arguments), args); }); - e.emit.apply(e, (["args"] as any[]).concat(args)); + e.emit.apply(e, ["args", ...args]); })(i); } }); @@ -108,7 +108,7 @@ describe("EventEmitter", function tests() { assert.deepStrictEqual(Array.prototype.slice.call(arguments), args); }); - e.emit.apply(e, (["args"] as any[]).concat(args)); + e.emit.apply(e, ["args", ...args]); })(i); } }); diff --git a/types/fibers/test/fibers.ts b/types/fibers/test/fibers.ts index 264c16c262eddd..f9272b9f84fdef 100644 --- a/types/fibers/test/fibers.ts +++ b/types/fibers/test/fibers.ts @@ -62,7 +62,7 @@ const fiberErrorTest = () => { while (true) { fn.run(); } - } catch (e) { + } catch (e: any) { console.log("safely caught that error!"); console.log(e.stack); } diff --git a/types/forge-viewer/forge-viewer-tests.ts b/types/forge-viewer/forge-viewer-tests.ts index 344617ee6e1843..4a87977d38efe3 100644 --- a/types/forge-viewer/forge-viewer-tests.ts +++ b/types/forge-viewer/forge-viewer-tests.ts @@ -753,9 +753,9 @@ async function cameraMappingTest(viewer: Autodesk.Viewing.GuiViewer3D): Promise< async function dbIdRemappingTest(viewer: Autodesk.Viewing.GuiViewer3D): Promise { // Override `PropDbLoader#load` so that the svf1/svf2 dbid mapping is always loaded. const _load = Autodesk.Viewing.Private.PropDbLoader.prototype.load; - Autodesk.Viewing.Private.PropDbLoader.prototype.load = function() { + Autodesk.Viewing.Private.PropDbLoader.prototype.load = function(options) { this.needsDbIdRemap = true; - _load.call(this); + _load.apply(this, options); }; // Override `PropDbLoader#processLoadResult` so that the dbid mapping is stored within all models (by default it is only stored in 2D models). diff --git a/types/forge-viewer/tsconfig.json b/types/forge-viewer/tsconfig.json index c93d8a767b426f..70217b05305575 100644 --- a/types/forge-viewer/tsconfig.json +++ b/types/forge-viewer/tsconfig.json @@ -6,10 +6,7 @@ "dom", "ES2020.String" ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, + "strict": true, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/gapi.calendar/gapi.calendar-tests.ts b/types/gapi.calendar/gapi.calendar-tests.ts index 406e7bb28eaeec..7621cad22f3991 100644 --- a/types/gapi.calendar/gapi.calendar-tests.ts +++ b/types/gapi.calendar/gapi.calendar-tests.ts @@ -1,5 +1,11 @@ /* Example taken from Google Calendar API JavaScript Quickstart https://developers.google.com/google-apps/calendar/quickstart/js */ +function appendPre(message: string) { + var pre = document.getElementById("output")!; + var textContent = document.createTextNode(message + "\n"); + pre.appendChild(textContent); +} + { // Your Client ID can be retrieved from your project in the Google // Developer Console, https://console.developers.google.com @@ -93,18 +99,6 @@ } }); } - - /** - * Append a pre element to the body containing the given message - * as its text node. - * - * @param {string} message Text to be placed in pre element. - */ - function appendPre(message: string) { - var pre = document.getElementById("output")!; - var textContent = document.createTextNode(message + "\n"); - pre.appendChild(textContent); - } } /* Example taken from https://developers.google.com/google-apps/calendar/v3/reference/events/insert#examples */ diff --git a/types/google-apps-script/test/google-apps-script-tests.ts b/types/google-apps-script/test/google-apps-script-tests.ts index ace7793f03f05f..9374b36be20e15 100644 --- a/types/google-apps-script/test/google-apps-script-tests.ts +++ b/types/google-apps-script/test/google-apps-script-tests.ts @@ -915,7 +915,7 @@ const handleCommonAction = (e: GoogleAppsScript.Addons.EventObject) => { props.setProperties(parameters); console.log(`Processed on ${formattedDate} at ${formattedTime} | ${userLocale}`); - } catch ({ name, message }) { + } catch ({ name, message }: any) { const type = plaformMap[platform]; console.warn(`Platform: ${type} Type: ${name} diff --git a/types/gun/gun-tests.ts b/types/gun/gun-tests.ts index fd47ca3a6716bc..c2d981616a2584 100644 --- a/types/gun/gun-tests.ts +++ b/types/gun/gun-tests.ts @@ -68,7 +68,7 @@ app.get("chatRoom").time!(msg => { app.get("object").time!({ a: 1 }); class X { - val: string; + val!: string; b() {} } interface BadState { diff --git a/types/hapi-decorators/hapi-decorators-tests.ts b/types/hapi-decorators/hapi-decorators-tests.ts index ee53f8b70da581..7592d636259380 100644 --- a/types/hapi-decorators/hapi-decorators-tests.ts +++ b/types/hapi-decorators/hapi-decorators-tests.ts @@ -3,8 +3,8 @@ import { cache, config, Controller, controller, get, post, put, route, validate @controller("/test") class TestController implements Controller { - baseUrl: string; - routes: () => hapi.RouteConfiguration[]; + baseUrl!: string; + routes!: () => hapi.RouteConfiguration[]; @get("/") @config({ @@ -48,8 +48,8 @@ class SimpleTestController implements Controller { this.foo = foo; } - baseUrl: string; - routes: () => hapi.RouteConfiguration[]; + baseUrl!: string; + routes!: () => hapi.RouteConfiguration[]; } server.route(new SimpleTestController("bar").routes()); diff --git a/types/hmscore__react-native-hms-push/test/main-test.tsx b/types/hmscore__react-native-hms-push/test/main-test.tsx index 3a7d75fa9c38bc..e62423d5acea77 100644 --- a/types/hmscore__react-native-hms-push/test/main-test.tsx +++ b/types/hmscore__react-native-hms-push/test/main-test.tsx @@ -35,16 +35,16 @@ interface State { } export default class App extends Component<{}, State> { - onRemoteMessageReceivedListener: NativeEventSubscription; - onTokenReceivedListener: NativeEventSubscription; - onTokenErrorListener: NativeEventSubscription; - onMultiSenderTokenReceivedListener: NativeEventSubscription; - onMultiSenderTokenErrorListener: NativeEventSubscription; - onPushMessageSentListener: NativeEventSubscription; - onMessageSentErrorListener: NativeEventSubscription; - onMessageSentDeliveredListener: NativeEventSubscription; - onLocalNotificationActionListener: NativeEventSubscription; - onNotificationOpenedAppListener: NativeEventSubscription; + onRemoteMessageReceivedListener!: NativeEventSubscription; + onTokenReceivedListener!: NativeEventSubscription; + onTokenErrorListener!: NativeEventSubscription; + onMultiSenderTokenReceivedListener!: NativeEventSubscription; + onMultiSenderTokenErrorListener!: NativeEventSubscription; + onPushMessageSentListener!: NativeEventSubscription; + onMessageSentErrorListener!: NativeEventSubscription; + onMessageSentDeliveredListener!: NativeEventSubscription; + onLocalNotificationActionListener!: NativeEventSubscription; + onNotificationOpenedAppListener!: NativeEventSubscription; constructor(props: {}) { super(props); diff --git a/types/image-to-base64/image-to-base64-tests.ts b/types/image-to-base64/image-to-base64-tests.ts index 58cdf67cfee567..1d55dd93ff0972 100644 --- a/types/image-to-base64/image-to-base64-tests.ts +++ b/types/image-to-base64/image-to-base64-tests.ts @@ -18,7 +18,7 @@ imageToBase64("https://whatever-image/") // Image URL (async () => { try { await imageToBase64("path/to/file.jpg"); // $ExpectType string - } catch (error) { + } catch (error: any) { error; // $ExpectType any } })(); diff --git a/types/intro.js/intro.js-tests.ts b/types/intro.js/intro.js-tests.ts index b91203ad3351a9..1c20bae750565c 100644 --- a/types/intro.js/intro.js-tests.ts +++ b/types/intro.js/intro.js-tests.ts @@ -128,7 +128,7 @@ introWithQuerySelector // test: intro.js should expose instance type #41108 class SomeClass { - introJsInstance: introJs.IntroJs; + introJsInstance!: introJs.IntroJs; someMethod() { this.introJsInstance = introJs(); diff --git a/types/is/is-tests.ts b/types/is/is-tests.ts index 3306ce18dfe9e9..ab428fc43e7e9a 100644 --- a/types/is/is-tests.ts +++ b/types/is/is-tests.ts @@ -3,12 +3,12 @@ var getArguments = function() { return arguments; }; -var arguments = getArguments(); -is.arguments(arguments); +var args = getArguments(); +is.arguments(args); is.not.arguments({ foo: "bar" }); -is.all.arguments(arguments, "bar"); -is.any.arguments(["foo"], arguments); -is.all.arguments([arguments, "foo", "bar"]); +is.all.arguments(args, "bar"); +is.any.arguments(["foo"], args); +is.all.arguments([args, "foo", "bar"]); is.array(["foo", "bar", "baz"]); is.not.array({ foo: "bar" }); diff --git a/types/jasmine/jasmine-tests.ts b/types/jasmine/jasmine-tests.ts index 7818e7e4c3bfcd..c5a60bc4d7d91f 100644 --- a/types/jasmine/jasmine-tests.ts +++ b/types/jasmine/jasmine-tests.ts @@ -1132,14 +1132,14 @@ describe("Spy for generic method", () => { describe("Multiple spies, when created manually", () => { class Tape { - private rewindTo: number; + private rewindTo!: number; play(): void {} pause(): void {} rewind(pos: number): void { this.rewindTo = pos; } stop(): void {} - readonly isPlaying: boolean; // spy obj makes this writable + readonly isPlaying!: boolean; // spy obj makes this writable } var tape: Tape; diff --git a/types/jasmine/v2/jasmine-tests.ts b/types/jasmine/v2/jasmine-tests.ts index 5d062860c67dd2..57f447bbb006df 100644 --- a/types/jasmine/v2/jasmine-tests.ts +++ b/types/jasmine/v2/jasmine-tests.ts @@ -652,14 +652,14 @@ describe("A spy, when created manually", () => { describe("Multiple spies, when created manually", () => { abstract class Tape { - private rewindTo: number; + private rewindTo!: number; play(): void {} pause(): void {} rewind(pos: number): void { this.rewindTo = pos; } stop(): void {} - readonly isPlaying: boolean; // spy obj makes this writable + readonly isPlaying!: boolean; // spy obj makes this writable } var tape: Tape; diff --git a/types/jasmine/v3/jasmine-tests.ts b/types/jasmine/v3/jasmine-tests.ts index b60197fc25cdaa..9ecc2df3062c75 100644 --- a/types/jasmine/v3/jasmine-tests.ts +++ b/types/jasmine/v3/jasmine-tests.ts @@ -1128,14 +1128,14 @@ describe("Spy for generic method", () => { describe("Multiple spies, when created manually", () => { class Tape { - private rewindTo: number; + private rewindTo!: number; play(): void {} pause(): void {} rewind(pos: number): void { this.rewindTo = pos; } stop(): void {} - readonly isPlaying: boolean; // spy obj makes this writable + readonly isPlaying!: boolean; // spy obj makes this writable } var tape: Tape; diff --git a/types/jasmine/v4/jasmine-tests.ts b/types/jasmine/v4/jasmine-tests.ts index 2eed86fac9e8a0..a95d0f896e0046 100644 --- a/types/jasmine/v4/jasmine-tests.ts +++ b/types/jasmine/v4/jasmine-tests.ts @@ -1126,14 +1126,14 @@ describe("Spy for generic method", () => { describe("Multiple spies, when created manually", () => { class Tape { - private rewindTo: number; + private rewindTo!: number; play(): void {} pause(): void {} rewind(pos: number): void { this.rewindTo = pos; } stop(): void {} - readonly isPlaying: boolean; // spy obj makes this writable + readonly isPlaying!: boolean; // spy obj makes this writable } var tape: Tape; diff --git a/types/javascript-natural-sort/.npmignore b/types/javascript-natural-sort/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/javascript-natural-sort/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/javascript-natural-sort/index.d.ts b/types/javascript-natural-sort/index.d.ts new file mode 100644 index 00000000000000..71f4398e91a436 --- /dev/null +++ b/types/javascript-natural-sort/index.d.ts @@ -0,0 +1,27 @@ +/** + * Natural sort comparison function for use with Array.sort(). + * Sorts strings containing numbers in a human-friendly way. + * + * @param a - First value to compare + * @param b - Second value to compare + * @returns Negative if a < b, positive if a > b, zero if equal + * + * @example + * ```javascript + * var naturalSort = require('javascript-natural-sort'); + * + * ['img12', 'img10', 'img2', 'img1'].sort(naturalSort); + * // => ['img1', 'img2', 'img10', 'img12'] + * ``` + */ +declare function naturalSort(a: string | number, b: string | number): number; + +declare namespace naturalSort { + /** + * Set to true to enable case-insensitive sorting. + * @default false + */ + let insensitive: boolean; +} + +export = naturalSort; diff --git a/types/javascript-natural-sort/javascript-natural-sort-tests.ts b/types/javascript-natural-sort/javascript-natural-sort-tests.ts new file mode 100644 index 00000000000000..7f1465609942f0 --- /dev/null +++ b/types/javascript-natural-sort/javascript-natural-sort-tests.ts @@ -0,0 +1,35 @@ +import naturalSort = require("javascript-natural-sort"); + +// Test basic usage with strings +const strings = ["img12", "img10", "img2", "img1"]; +const sortedStrings: string[] = strings.sort(naturalSort); + +// Test with numbers +const numbers = [10, 2, 1, 12]; +const sortedNumbers: number[] = numbers.sort(naturalSort); + +// Test with mixed content +const mixed = ["a10", "a2", "a1"]; +mixed.sort(naturalSort); + +// Test case-insensitive mode +naturalSort.insensitive = true; +const caseInsensitive = ["B", "a", "C"].sort(naturalSort); + +// Reset +naturalSort.insensitive = false; + +// Test direct comparison +const result: number = naturalSort("img2", "img10"); + +// Test with version numbers +const versions = ["1.0.10", "1.0.2", "1.0.1"]; +versions.sort(naturalSort); + +// Test with dates +const dates = ["2023-01-10", "2023-01-2", "2023-01-1"]; +dates.sort(naturalSort); + +// Test with hex values +const hex = ["0x10", "0x2", "0x1"]; +hex.sort(naturalSort); diff --git a/types/javascript-natural-sort/package.json b/types/javascript-natural-sort/package.json new file mode 100644 index 00000000000000..56a92298a208e2 --- /dev/null +++ b/types/javascript-natural-sort/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/javascript-natural-sort", + "version": "0.7.9999", + "projects": [ + "https://github.com/Bill4Time/javascript-natural-sort" + ], + "devDependencies": { + "@types/javascript-natural-sort": "workspace:." + }, + "owners": [ + { + "name": "gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/javascript-natural-sort/tsconfig.json b/types/javascript-natural-sort/tsconfig.json new file mode 100644 index 00000000000000..e84c912cf5cb30 --- /dev/null +++ b/types/javascript-natural-sort/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", + "javascript-natural-sort-tests.ts" + ] +} diff --git a/types/jest-specific-snapshot/index.d.ts b/types/jest-specific-snapshot/index.d.ts index 629f56f593a0c1..320b5ad2ca8904 100644 --- a/types/jest-specific-snapshot/index.d.ts +++ b/types/jest-specific-snapshot/index.d.ts @@ -19,7 +19,8 @@ export function addSerializer(serializer: any): void; * This is used to create a customized version of toMatchSpecificSnapshot. */ export function toMatchSpecificSnapshot( + this: jest.MatcherContext, data: any, snapshotFile: string, - testName: string, -): () => { message(): string; pass: boolean }; + testName?: string, +): { message(): string; pass: boolean }; diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 36e622ad440aa1..2adc255b71e7a4 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -782,7 +782,7 @@ interface Type2 { b: number; } class TestMocked { - field: string; + field!: string; test1(x: Type1): Promise { return Promise.resolve(x); } diff --git a/types/jexl/jexl-tests.ts b/types/jexl/jexl-tests.ts index ebbd957e78aa11..aa81d664f46159 100644 --- a/types/jexl/jexl-tests.ts +++ b/types/jexl/jexl-tests.ts @@ -108,7 +108,7 @@ jexl.eval("\"Guest\" _= \"gUeSt\""); try { const asyncTransform = await jexl.eval("name.last|getStat(\"weight\")", context); console.log("9. Async Transform", asyncTransform); // Output: 184 - } catch (e) { + } catch (e: any) { console.log("Database Error", e.stack); } @@ -128,7 +128,7 @@ jexl.eval("\"Guest\" _= \"gUeSt\""); try { const asyncFunc = await jexl.eval("age > calculateAge(20, 21)"); console.log("12. Async Function", asyncFunc); // false - } catch (e) { + } catch (e: any) { console.log("Calculation Error", e.stack); } })().then(() => console.log("Testing done")); diff --git a/types/jfp/jfp-tests.ts b/types/jfp/jfp-tests.ts index adcb2d9f4222f1..f46050481062c2 100644 --- a/types/jfp/jfp-tests.ts +++ b/types/jfp/jfp-tests.ts @@ -9,7 +9,7 @@ j.always(true)(); j.and(true, false) === false; j.apply(testFn, [1, 2, 3]); j.between([3, 7], 5) === true; -j.call(testFn, 1, 2, 3); +j.call(testFn, null as any, 1, 2, 3); j.clone({}); j.compact([]); j.compose(testFn, testFn)(); diff --git a/types/jfp/tsconfig.json b/types/jfp/tsconfig.json index abc2b77eb99cdd..1d1b9a01accf1b 100644 --- a/types/jfp/tsconfig.json +++ b/types/jfp/tsconfig.json @@ -4,10 +4,7 @@ "lib": [ "es6" ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, + "strict": true, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/jquery-mask-plugin/jquery-mask-plugin-tests.ts b/types/jquery-mask-plugin/jquery-mask-plugin-tests.ts index 4f02b1225cc7f0..0c83b9da348f6b 100644 --- a/types/jquery-mask-plugin/jquery-mask-plugin-tests.ts +++ b/types/jquery-mask-plugin/jquery-mask-plugin-tests.ts @@ -96,7 +96,7 @@ let maskBehavior: (value: string) => string = val => { options = { onKeyPress(val: string, e: Event, field: JQuery, options: jQueryMask.Options) { - field.mask(maskBehavior.apply({}, arguments), options); + field.mask(maskBehavior(val), options); }, }; diff --git a/types/jquery.bbq/jquery.bbq-tests.ts b/types/jquery.bbq/jquery.bbq-tests.ts index 8fb5a3a357559d..02755d2ef1b6e4 100644 --- a/types/jquery.bbq/jquery.bbq-tests.ts +++ b/types/jquery.bbq/jquery.bbq-tests.ts @@ -228,7 +228,10 @@ $(function() { // START CLOSURE run_many_tests( // execute this for each array item function() { - current_url = $.param.querystring.apply(this, [current_url].concat(aps.call(arguments))); + current_url = $.param.querystring.apply( + this, + [current_url].concat(aps.call(arguments)) as [string?, any?, number?], + ); }, // tests: @@ -399,7 +402,10 @@ $(function() { // START CLOSURE run_many_tests( // execute this for each array item function() { - current_url = $.param.fragment.apply(this, [current_url].concat(aps.call(arguments))); + current_url = $.param.fragment.apply( + this, + [current_url].concat(aps.call(arguments)) as [string, any, number?], + ); }, // tests: @@ -1228,7 +1234,7 @@ $(function() { // START CLOSURE // execute this for each array item function() { notice(msg += "."); - $.bbq.pushState.apply(this, aps.call(arguments)); + $.bbq.pushState.apply(this, aps.call(arguments) as [any?, number?]); }, // execute this at the end function() { diff --git a/types/jquery.cookie/jquery.cookie-tests.ts b/types/jquery.cookie/jquery.cookie-tests.ts index d239dce3023e02..59b093c4662fd6 100644 --- a/types/jquery.cookie/jquery.cookie-tests.ts +++ b/types/jquery.cookie/jquery.cookie-tests.ts @@ -9,10 +9,10 @@ class TestObject { } class CookieOptions implements JQueryCookieOptions { - expires: number; - path: string; - domain: string; - secure: boolean; + expires!: number; + path!: string; + domain!: string; + secure!: boolean; } $.cookie("the_cookie", "the_value"); diff --git a/types/jquery.leanmodal/jquery.leanmodal-tests.ts b/types/jquery.leanmodal/jquery.leanmodal-tests.ts index ca72c6a000b825..bd29ab845e5eed 100644 --- a/types/jquery.leanmodal/jquery.leanmodal-tests.ts +++ b/types/jquery.leanmodal/jquery.leanmodal-tests.ts @@ -1,7 +1,7 @@ class LeanModalOptions implements JQueryLeanModalOption { - top: number; - overlay: number; - closeButton: string; + top!: number; + overlay!: number; + closeButton!: string; } $.leanModal(); diff --git a/types/jquery/test/learn-tests.ts b/types/jquery/test/learn-tests.ts index c0cc4992834911..215679b2b9c774 100644 --- a/types/jquery/test/learn-tests.ts +++ b/types/jquery/test/learn-tests.ts @@ -42,7 +42,10 @@ function special() { if (targetData.clicks % event.data.clicks === 0) { event.type = handleObj.origType; - ret = handleObj.handler.apply(this, arguments); + ret = handleObj.handler.apply( + this, + arguments as unknown as [JQuery.TriggeredEvent, ...any[]], + ); event.type = handleObj.type; return ret; } diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index e3961bfc1cff24..b1c61219d62746 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -19,7 +19,7 @@ const salesforceConnection: sf.Connection = new sf.Connection({ if (callback) { callback(null, conn.accessToken, userInfo); } - } catch (err) { + } catch (err: any) { if (callback) { callback(err, conn.accessToken); } diff --git a/types/karma/karma-tests.ts b/types/karma/karma-tests.ts index 2ef5ad92377204..6bff22b67e8ae9 100644 --- a/types/karma/karma-tests.ts +++ b/types/karma/karma-tests.ts @@ -201,7 +201,7 @@ CustomPlugin.prototype = { log: () => {}, }; class CustomPluginClass { - log: () => {}; + log!: () => void; } const pluginsTests = (config: Config) => { diff --git a/types/knockout/test/index.ts b/types/knockout/test/index.ts index 13df0739b1a080..455809157b678a 100644 --- a/types/knockout/test/index.ts +++ b/types/knockout/test/index.ts @@ -93,7 +93,7 @@ class GetterViewModel { this._selectedRange = ko.observable(); } - public range: KnockoutObservable; + public range!: KnockoutObservable; } function testToJs() { @@ -529,7 +529,16 @@ function test_misc() { read: function() { ko.utils.unwrapObservable(valueAccessor()); if (ko.bindingHandlers.options.update) { - ko.bindingHandlers.options.update.apply(this, args); + ko.bindingHandlers.options.update.apply( + this, + args as unknown as [ + any, + () => any, + KnockoutAllBindingsAccessor, + any, + KnockoutBindingContext, + ], + ); } }, owner: this, diff --git a/types/knockout/test/templatingBehaviors.ts b/types/knockout/test/templatingBehaviors.ts index e909c4d21dc3cc..1a39c335118341 100644 --- a/types/knockout/test/templatingBehaviors.ts +++ b/types/knockout/test/templatingBehaviors.ts @@ -82,7 +82,7 @@ var dummyTemplateEngine = function(templates?) { try { var evalResult = eval(script); return (evalResult === null) || (evalResult === undefined) ? "" : evalResult.toString(); - } catch (ex) { + } catch (ex: any) { throw new Error( "Error evaluating script: [js: " + script + "]\n\nException: " + ex.toString(), ); @@ -107,7 +107,7 @@ var dummyTemplateEngine = function(templates?) { // Only rewrite if the template isn't a function (can't rewrite those) var templateSource = new ko.templateSources.anonymousTemplate(template); // this.makeTemplateSource(template); if (typeof templateSource.text() != "function") { - return ko.templateEngine.prototype.rewriteTemplate.call(this, template, rewriterCallback); + return ko.templateEngine.prototype.rewriteTemplate.call(this, template, rewriterCallback, document); } }; this.createJavaScriptEvaluatorBlock = function(script) { @@ -135,7 +135,7 @@ describe("Templating", function() { ko.setTemplateEngine(undefined); try { ko.renderTemplate("someTemplate", {}); - } catch (ex) { + } catch (ex: any) { threw = true; } expect(threw).toEqual(true); @@ -971,7 +971,7 @@ describe("Templating", function() { var didThrow = false; try { ko.applyBindings({ someData: { childProp: "abc" } }, testNode); - } catch (ex) { + } catch (ex: any) { didThrow = true; expect(ex.message).toEqual( "This template engine does not support anonymous templates nested within its templates", @@ -994,7 +994,7 @@ describe("Templating", function() { ko.utils.domData.clear(testNode); try { ko.applyBindings({ someData: { childProp: "abc" } }, testNode); - } catch (ex) { + } catch (ex: any) { didThrow = true; expect(ex.message).toEqual( "This template engine does not support the '" + bindingName + "' binding within its templates", diff --git a/types/koa/test/index.ts b/types/koa/test/index.ts index 60b5f32fa14d70..5e64ec35b50455 100644 --- a/types/koa/test/index.ts +++ b/types/koa/test/index.ts @@ -35,7 +35,7 @@ app.use(async ctx => { app.use(async (ctx, next) => { try { return await next(); - } catch (ex) { + } catch (ex: any) { ctx.errors = [ex]; } }); diff --git a/types/libpq/libpq-tests.ts b/types/libpq/libpq-tests.ts index ec78e31170e663..7fe6fa0274d019 100644 --- a/types/libpq/libpq-tests.ts +++ b/types/libpq/libpq-tests.ts @@ -643,7 +643,7 @@ describe("connecting with bad credentials", () => { it("throws an error", () => { try { new PQ().connectSync("asldkfjlasdf"); - } catch (e) { + } catch (e: any) { assert.equal(e.toString().indexOf("connection pointer is NULL"), -1); return; } diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 9d02f7e4a6f430..b68e541f481522 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -4419,7 +4419,7 @@ fp.now(); // $ExpectType number { class CustomError extends Error { - custom: string; + custom!: string; } const value: number | CustomError = anything; diff --git a/types/lokijs/lokijs-tests.ts b/types/lokijs/lokijs-tests.ts index 1557f316d6b826..31d1c134eba698 100644 --- a/types/lokijs/lokijs-tests.ts +++ b/types/lokijs/lokijs-tests.ts @@ -14,10 +14,10 @@ class Ant { static uniqueId = 1; id: number; - dob: Date; - health: number; // range [0.0, 1.0] - lengthMm: number; // in millimeters - weightMg: number; // in milligrams + dob!: Date; + health!: number; // range [0.0, 1.0] + lengthMm!: number; // in millimeters + weightMg!: number; // in milligrams constructor(id: number) { this.id = id; @@ -29,7 +29,7 @@ class Ant { } class QueenAnt extends Ant { - eggsBirthed: number; + eggsBirthed!: number; constructor(id: number) { super(id); diff --git a/types/loopback/loopback-tests.ts b/types/loopback/loopback-tests.ts index 6400ac6a1df8a8..c4d39f50f0b5cd 100644 --- a/types/loopback/loopback-tests.ts +++ b/types/loopback/loopback-tests.ts @@ -2,8 +2,8 @@ import loopback = require("loopback"); import cookieParser = require("cookie-parser"); class TestModel { - id: number; - name: string; + id!: number; + name!: string; } class Server { diff --git a/types/ltx/ltx-tests.ts b/types/ltx/ltx-tests.ts index 0e51b6dc84011a..e690aec7ac4e3b 100644 --- a/types/ltx/ltx-tests.ts +++ b/types/ltx/ltx-tests.ts @@ -163,7 +163,7 @@ el.tree(); // $ExpectType Element el.up(); // $ExpectType Element class MyEl extends ltx.Element { - foo: "bar"; + foo!: "bar"; } const myEl = new MyEl("el"); diff --git a/types/mdns/mdns-tests.ts b/types/mdns/mdns-tests.ts index ec30fcb6496b19..3013618ca89dc0 100644 --- a/types/mdns/mdns-tests.ts +++ b/types/mdns/mdns-tests.ts @@ -64,8 +64,8 @@ function createAdvertisement() { ad = mdns.createAdvertisement(mdns.tcp("http"), 1337); ad.on("error", handleError); ad.start(); - } catch (ex) { - handleError(ex); + } catch (ex: any) { + handleError(ex as mdns.DnsSdError); } } diff --git a/types/microsoft-ajax/microsoft-ajax-tests.ts b/types/microsoft-ajax/microsoft-ajax-tests.ts index e0d019f69dd86c..d4405046ef0043 100644 --- a/types/microsoft-ajax/microsoft-ajax-tests.ts +++ b/types/microsoft-ajax/microsoft-ajax-tests.ts @@ -91,9 +91,9 @@ function BaseClassExtensions_Function_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx */ var validateParametersTest = function() { - var arguments = ["test1", "test2"]; + var args = ["test1", "test2"]; var insert = function Array$insert(array: any[], index: number, item: any) { - var e = Function.validateParameters(arguments, [ + var e = Function.validateParameters(args, [ { name: "array", type: Array, elementMayBeNull: true }, { name: "index", mayBeNull: true }, { name: "item", mayBeNull: true }, diff --git a/types/new-relic-browser/new-relic-browser-tests.ts b/types/new-relic-browser/new-relic-browser-tests.ts index b91a2f74e2be60..5a628ab5162237 100644 --- a/types/new-relic-browser/new-relic-browser-tests.ts +++ b/types/new-relic-browser/new-relic-browser-tests.ts @@ -29,7 +29,7 @@ newrelic.finished(); // noticeError() try { JSON.parse("{ \"bar\""); -} catch (err) { +} catch (err: any) { newrelic.noticeError(err); } newrelic.noticeError(new Error("bar")); diff --git a/types/node-fibers/node-fibers-tests.ts b/types/node-fibers/node-fibers-tests.ts index 317c2a69173fd7..74bd42e7d40e60 100644 --- a/types/node-fibers/node-fibers-tests.ts +++ b/types/node-fibers/node-fibers-tests.ts @@ -68,7 +68,7 @@ try { while (true) { fn.run(); } -} catch (e) { +} catch (e: any) { console.log("safely caught that error!"); console.log(e.stack); } diff --git a/types/node-mysql-wrapper/node-mysql-wrapper-tests.ts b/types/node-mysql-wrapper/node-mysql-wrapper-tests.ts index 3cf6f3b3ce54e2..a8b19a41d1ad21 100644 --- a/types/node-mysql-wrapper/node-mysql-wrapper-tests.ts +++ b/types/node-mysql-wrapper/node-mysql-wrapper-tests.ts @@ -5,13 +5,13 @@ import wrapper2 = require("node-mysql-wrapper"); var db = wrapper2.wrap("mysql://kataras:pass@127.0.0.1/taglub?debug=false&charset=utf8"); class User { // or interface - userId: number; - username: string; - mail: string; - password: string; - comments: Comment[]; - myComments: Comment[]; - info: UserInfo; + userId!: number; + username!: string; + mail!: string; + password!: string; + comments!: Comment[]; + myComments!: Comment[]; + info!: UserInfo; } interface Comment { diff --git a/types/node/node-tests/http.ts b/types/node/node-tests/http.ts index b3f02bf938f290..74e6be671509fd 100644 --- a/types/node/node-tests/http.ts +++ b/types/node/node-tests/http.ts @@ -12,13 +12,13 @@ import * as url from "node:url"; let server: http.Server = new http.Server(); class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } server = new http.Server({ IncomingMessage: MyIncomingMessage }); @@ -77,13 +77,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends MyIncomingMessage = MyIncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; getFoo() { return this.req.foo; diff --git a/types/node/node-tests/http2.ts b/types/node/node-tests/http2.ts index 0756727505d02f..a41bfa7c10eb32 100644 --- a/types/node/node-tests/http2.ts +++ b/types/node/node-tests/http2.ts @@ -439,13 +439,13 @@ import { URL } from "node:url"; // Http2ServerRequest, Http2ServerResponse, { class MyHttp2ServerRequest extends Http2ServerRequest { - foo: number; + foo!: number; } class MyHttp2ServerResponse extends Http2ServerResponse { - bar: string; + bar!: string; } function reqListener(req: Http2ServerRequest, res: Http2ServerResponse): void {} diff --git a/types/node/node-tests/https.ts b/types/node/node-tests/https.ts index 80ebf08a4dd0db..aa9209df1cd95b 100644 --- a/types/node/node-tests/https.ts +++ b/types/node/node-tests/https.ts @@ -77,13 +77,13 @@ import * as url from "node:url"; function reqListener(req: http.IncomingMessage, res: http.ServerResponse): void {} class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } let server: https.Server; @@ -127,13 +127,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends http.IncomingMessage = http.IncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; } function reqListener(req: MyIncomingMessage, res: MyServerResponse): void {} diff --git a/types/node/v20/test/http.ts b/types/node/v20/test/http.ts index 5538dd7ff8619e..8a39697747a2bb 100644 --- a/types/node/v20/test/http.ts +++ b/types/node/v20/test/http.ts @@ -11,13 +11,13 @@ import * as url from "node:url"; let server: http.Server = new http.Server(); class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } server = new http.Server({ IncomingMessage: MyIncomingMessage }); @@ -69,13 +69,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends http.IncomingMessage = http.IncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; } function reqListener(req: MyIncomingMessage, res: MyServerResponse): void {} diff --git a/types/node/v20/test/http2.ts b/types/node/v20/test/http2.ts index 31dd548cbd010a..ce346c5a2ad7f8 100644 --- a/types/node/v20/test/http2.ts +++ b/types/node/v20/test/http2.ts @@ -434,13 +434,13 @@ import { URL } from "node:url"; // Http2ServerRequest, Http2ServerResponse, { class MyHttp2ServerRequest extends Http2ServerRequest { - foo: number; + foo!: number; } class MyHttp2ServerResponse extends Http2ServerResponse { - bar: string; + bar!: string; } function reqListener(req: Http2ServerRequest, res: Http2ServerResponse): void {} diff --git a/types/node/v20/test/https.ts b/types/node/v20/test/https.ts index e537ce0f4f92f6..67addcc1ebf96c 100644 --- a/types/node/v20/test/https.ts +++ b/types/node/v20/test/https.ts @@ -74,13 +74,13 @@ import * as url from "node:url"; function reqListener(req: http.IncomingMessage, res: http.ServerResponse): void {} class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } let server: https.Server; @@ -123,13 +123,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends http.IncomingMessage = http.IncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; } function reqListener(req: MyIncomingMessage, res: MyServerResponse): void {} diff --git a/types/node/v22/test/http.ts b/types/node/v22/test/http.ts index ffc869f75389ce..cc8b1d25816110 100644 --- a/types/node/v22/test/http.ts +++ b/types/node/v22/test/http.ts @@ -11,13 +11,13 @@ import * as url from "node:url"; let server: http.Server = new http.Server(); class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } server = new http.Server({ IncomingMessage: MyIncomingMessage }); @@ -71,13 +71,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends MyIncomingMessage = MyIncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; getFoo() { return this.req.foo; diff --git a/types/node/v22/test/http2.ts b/types/node/v22/test/http2.ts index 09eec774c35227..2989c8a82b8f36 100644 --- a/types/node/v22/test/http2.ts +++ b/types/node/v22/test/http2.ts @@ -436,13 +436,13 @@ import { URL } from "node:url"; // Http2ServerRequest, Http2ServerResponse, { class MyHttp2ServerRequest extends Http2ServerRequest { - foo: number; + foo!: number; } class MyHttp2ServerResponse extends Http2ServerResponse { - bar: string; + bar!: string; } function reqListener(req: Http2ServerRequest, res: Http2ServerResponse): void {} diff --git a/types/node/v22/test/https.ts b/types/node/v22/test/https.ts index c7cd79a7fc3df2..b70b33c9ab3b8a 100644 --- a/types/node/v22/test/https.ts +++ b/types/node/v22/test/https.ts @@ -74,13 +74,13 @@ import * as url from "node:url"; function reqListener(req: http.IncomingMessage, res: http.ServerResponse): void {} class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } let server: https.Server; @@ -124,13 +124,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends http.IncomingMessage = http.IncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; } function reqListener(req: MyIncomingMessage, res: MyServerResponse): void {} diff --git a/types/node/v24/test/http.ts b/types/node/v24/test/http.ts index 102ba8e6eb408e..807785905ec39f 100644 --- a/types/node/v24/test/http.ts +++ b/types/node/v24/test/http.ts @@ -11,13 +11,13 @@ import * as url from "node:url"; let server: http.Server = new http.Server(); class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } server = new http.Server({ IncomingMessage: MyIncomingMessage }); @@ -75,13 +75,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends MyIncomingMessage = MyIncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; getFoo() { return this.req.foo; diff --git a/types/node/v24/test/http2.ts b/types/node/v24/test/http2.ts index 0756727505d02f..a41bfa7c10eb32 100644 --- a/types/node/v24/test/http2.ts +++ b/types/node/v24/test/http2.ts @@ -439,13 +439,13 @@ import { URL } from "node:url"; // Http2ServerRequest, Http2ServerResponse, { class MyHttp2ServerRequest extends Http2ServerRequest { - foo: number; + foo!: number; } class MyHttp2ServerResponse extends Http2ServerResponse { - bar: string; + bar!: string; } function reqListener(req: Http2ServerRequest, res: Http2ServerResponse): void {} diff --git a/types/node/v24/test/https.ts b/types/node/v24/test/https.ts index 75d628e9a3f932..b3f54db7cde511 100644 --- a/types/node/v24/test/https.ts +++ b/types/node/v24/test/https.ts @@ -77,13 +77,13 @@ import * as url from "node:url"; function reqListener(req: http.IncomingMessage, res: http.ServerResponse): void {} class MyIncomingMessage extends http.IncomingMessage { - foo: number; + foo!: number; } class MyServerResponse extends http.ServerResponse { - foo: string; + foo!: string; } let server: https.Server; @@ -127,13 +127,13 @@ import * as url from "node:url"; let bar: "bar"; class MyIncomingMessage extends http.IncomingMessage { - foo: typeof foo; + foo!: typeof foo; } class MyServerResponse< Request extends http.IncomingMessage = http.IncomingMessage, > extends http.ServerResponse { - bar: typeof bar; + bar!: typeof bar; } function reqListener(req: MyIncomingMessage, res: MyServerResponse): void {} diff --git a/types/oauth2-server/oauth2-server-tests.ts b/types/oauth2-server/oauth2-server-tests.ts index 41772b584005db..c0b659309ae62b 100644 --- a/types/oauth2-server/oauth2-server-tests.ts +++ b/types/oauth2-server/oauth2-server-tests.ts @@ -80,7 +80,7 @@ const authenticate = (authenticateOptions?: {}) => { const token = await oauth2Server.authenticate(request, response, options); req.user = token; next(); - } catch (err) { + } catch (err: any) { res.status(err.code || 500).json(err); } }; diff --git a/types/oauth2orize/oauth2orize-tests.ts b/types/oauth2orize/oauth2orize-tests.ts index 6642d9e5b9c5b9..d6cdc6c8a17fca 100644 --- a/types/oauth2orize/oauth2orize-tests.ts +++ b/types/oauth2orize/oauth2orize-tests.ts @@ -100,8 +100,8 @@ class Clients { static findOne(id: string, callback: (err: Error, client?: Clients) => void): void { callback(new Error(), {} as Clients); // tslint:disable-line no-object-literal-type-assertion } - id: string; - redirectURI: string; + id!: string; + redirectURI!: string; } declare global { diff --git a/types/oled-font-5x7/.npmignore b/types/oled-font-5x7/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/oled-font-5x7/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/oled-font-5x7/index.d.ts b/types/oled-font-5x7/index.d.ts new file mode 100644 index 00000000000000..77910ab4a73973 --- /dev/null +++ b/types/oled-font-5x7/index.d.ts @@ -0,0 +1,9 @@ +declare const Font: { + monospace: boolean; + width: number; + height: number; + fontData: number[]; + lookup: string[]; +}; + +export = Font; diff --git a/types/oled-font-5x7/oled-font-5x7-tests.ts b/types/oled-font-5x7/oled-font-5x7-tests.ts new file mode 100644 index 00000000000000..26a74ff5e56d02 --- /dev/null +++ b/types/oled-font-5x7/oled-font-5x7-tests.ts @@ -0,0 +1,23 @@ +import font = require("oled-font-5x7"); + +// $ExpectType boolean +font.monospace; + +// $ExpectType number +font.width; + +// $ExpectType number +font.height; + +// $ExpectType number[] +font.fontData; + +// $ExpectType string[] +font.lookup; + +// Test that values are accessible +const isMonospace: boolean = font.monospace; +const charWidth: number = font.width; +const charHeight: number = font.height; +const data: number[] = font.fontData; +const chars: string[] = font.lookup; diff --git a/types/oled-font-5x7/package.json b/types/oled-font-5x7/package.json new file mode 100644 index 00000000000000..c02862d3d4a789 --- /dev/null +++ b/types/oled-font-5x7/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "name": "@types/oled-font-5x7", + "version": "1.0.9999", + "projects": [ + "https://github.com/noopkat/oled-font-5x7" + ], + "devDependencies": { + "@types/oled-font-5x7": "workspace:." + }, + "owners": [ + { + "name": "Gaspard", + "githubUsername": "gasp" + } + ] +} diff --git a/types/oled-font-5x7/tsconfig.json b/types/oled-font-5x7/tsconfig.json new file mode 100644 index 00000000000000..88d2f0fc243b85 --- /dev/null +++ b/types/oled-font-5x7/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "oled-font-5x7-tests.ts"] +} diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index a4f4784f7fe76a..d398b0683c85fa 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -298,7 +298,7 @@ const runPromiseTests = async (): Promise => { console.log("Testing pool.close()..."); await pool.close(5); - } catch (err) { + } catch (err: any) { console.log(err.message); } }; diff --git a/types/oracledb/v3/oracledb-tests.ts b/types/oracledb/v3/oracledb-tests.ts index cb858c45c15b0e..0d36c677afde6e 100644 --- a/types/oracledb/v3/oracledb-tests.ts +++ b/types/oracledb/v3/oracledb-tests.ts @@ -288,7 +288,7 @@ const runPromiseTests = async (): Promise => { console.log("Testing pool.close()..."); await pool.close(5); - } catch (err) { + } catch (err: any) { console.log(err.message); } }; diff --git a/types/parcel-env/parcel-env-tests.ts b/types/parcel-env/parcel-env-tests.ts index ebfedbd25fc93f..fff4ec3af00e0e 100644 --- a/types/parcel-env/parcel-env-tests.ts +++ b/types/parcel-env/parcel-env-tests.ts @@ -13,7 +13,7 @@ otherModule.otherMethod(); module.exports = null; class ModuleData { - updated: boolean; + updated!: boolean; } // check if HMR is enabled diff --git a/types/parsimmon/parsimmon-tests.ts b/types/parsimmon/parsimmon-tests.ts index 0f142f2a0a849c..a402b61704e99a 100644 --- a/types/parsimmon/parsimmon-tests.ts +++ b/types/parsimmon/parsimmon-tests.ts @@ -4,11 +4,11 @@ import { Index, Language, Mark, Parser, Reply, Result, TypedLanguage } from "par // -- -- -- -- -- -- -- -- -- -- -- -- -- class Foo { - bar: Bar; + bar!: Bar; } class Bar { - foo: Foo; + foo!: Foo; } // -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/types/passport-auth-token/passport-auth-token-tests.ts b/types/passport-auth-token/passport-auth-token-tests.ts index 2fdb4937caf1bc..8f66b2ff64bacb 100644 --- a/types/passport-auth-token/passport-auth-token-tests.ts +++ b/types/passport-auth-token/passport-auth-token-tests.ts @@ -21,8 +21,8 @@ testingAuthTokenStrategy.success = () => {}; testingAuthTokenStrategy.fail = () => {}; class AccessTokenImpl implements AccessToken { - id: string; - userId: string; + id!: string; + userId!: string; static findOne(token: AccessToken, callback: (token: AccessTokenImpl, err?: Error) => void): void { callback(new AccessTokenImpl(), undefined); @@ -34,7 +34,7 @@ class AccessTokenImpl implements AccessToken { } class UserImpl implements User { - id: string; + id!: string; static findOne(user: User, callback: (user: UserImpl, err?: Error) => void): void { callback(new UserImpl(), undefined); } diff --git a/types/passport-oauth2-client-password/passport-oauth2-client-password-tests.ts b/types/passport-oauth2-client-password/passport-oauth2-client-password-tests.ts index ea8d646caf1a35..88e22799487002 100644 --- a/types/passport-oauth2-client-password/passport-oauth2-client-password-tests.ts +++ b/types/passport-oauth2-client-password/passport-oauth2-client-password-tests.ts @@ -13,8 +13,8 @@ interface IClient { } class Client implements IClient { - public clientId: string; - public clientSecret: string; + public clientId!: string; + public clientSecret!: string; static findOne(client: IClient, callback: (err: any, client: Client) => void): void { callback(null, new Client()); diff --git a/types/passport-unique-token/passport-unique-token-tests.ts b/types/passport-unique-token/passport-unique-token-tests.ts index 87492eb4f9d347..ef362ae2df9e27 100644 --- a/types/passport-unique-token/passport-unique-token-tests.ts +++ b/types/passport-unique-token/passport-unique-token-tests.ts @@ -13,7 +13,7 @@ interface BaseUser { } class User implements BaseUser { - uniqueToken: string; + uniqueToken!: string; static findOne(user: BaseUser & any, callback: (err: Error | null, user: User) => void): void { callback(null, new User()); diff --git a/types/peer-dial/peer-dial-tests.ts b/types/peer-dial/peer-dial-tests.ts index 11a6ba9fa0d89b..2eb6ec73c2cf0b 100644 --- a/types/peer-dial/peer-dial-tests.ts +++ b/types/peer-dial/peer-dial-tests.ts @@ -2,10 +2,10 @@ import { App, AppInfo, Client, CorsOptions, Delegate, DeviceInfo, DialDevice, Se import express = require("express"); class AppImpl implements App { - name: string; - state: string; - allowStop: boolean; - pid: string; + name!: string; + state!: string; + allowStop!: boolean; + pid!: string; launch(launchData: string): void { } } diff --git a/types/pegjs/pegjs-tests.ts b/types/pegjs/pegjs-tests.ts index a8de241872ab01..fae2efcadf854e 100644 --- a/types/pegjs/pegjs-tests.ts +++ b/types/pegjs/pegjs-tests.ts @@ -10,7 +10,7 @@ import * as pegjs from "pegjs"; try { let result: string = pegparser.parse("abba"); - } catch (error) { + } catch (error: any) { if (error instanceof pegparser.SyntaxError) { } } @@ -32,7 +32,7 @@ import * as pegjs from "pegjs"; try { let source: string = pegjs.generate("A = 'test'", { output: "source" }); -} catch (error) { +} catch (error: any) { if (error instanceof pegjs.GrammarError) { let e: pegjs.GrammarError = error; } else if (error instanceof pegjs.parser.SyntaxError) { diff --git a/types/pendo-io-browser/pendo-io-browser-tests.ts b/types/pendo-io-browser/pendo-io-browser-tests.ts index e61c984ccaaf94..647410fd37ee68 100644 --- a/types/pendo-io-browser/pendo-io-browser-tests.ts +++ b/types/pendo-io-browser/pendo-io-browser-tests.ts @@ -141,7 +141,7 @@ pendo.track("User Registered", { try { throw new Error(); -} catch (error) { +} catch (error: any) { pendo.track("JIRA-12345--error-tripped", { message: error.message, stack: error.stack, diff --git a/types/polymer/polymer-tests.ts b/types/polymer/polymer-tests.ts index 5cd455152041fc..11697de1b4d9f9 100644 --- a/types/polymer/polymer-tests.ts +++ b/types/polymer/polymer-tests.ts @@ -69,7 +69,7 @@ var el2 = document.createElement("my-element"); // implicit implementation class MyElement2 { - is: string; + is!: string; beforeRegister() { this.is = "my-element2"; @@ -80,7 +80,7 @@ Polymer(MyElement2); // explicit implementation class MyElement3 implements polymer.Base { - is: string; + is!: string; beforeRegister() { this.is = "my-element3"; diff --git a/types/qs/qs-tests.ts b/types/qs/qs-tests.ts index 3c32e1dda03985..38fc7a5f811b4b 100644 --- a/types/qs/qs-tests.ts +++ b/types/qs/qs-tests.ts @@ -406,7 +406,7 @@ qs.parse("a=b&c=d", { delimiter: "&" }); (() => { try { qs.parse("a[b][c][d][e][f][g][h][i]=j", { depth: 1, strictDepth: true }); - } catch (err) { + } catch (err: any) { assert.strictEqual(err.message, "Input depth exceeded depth option of 1 and strictDepth is true"); } }); diff --git a/types/qunit/v1/qunit-tests.ts b/types/qunit/v1/qunit-tests.ts index 6fc00a33711671..5ba42e8c8b0739 100644 --- a/types/qunit/v1/qunit-tests.ts +++ b/types/qunit/v1/qunit-tests.ts @@ -1596,7 +1596,7 @@ test("Circular reference - test reported by soniciq in #105", function() { expect(0); QUnit.reset = function() { ok(false, "reset should not modify test status"); - reset.apply(this, arguments); + reset.call(this); }; }); test("reset runs assertions, cleanup", function() { diff --git a/types/raven/raven-tests.ts b/types/raven/raven-tests.ts index d2a9344a45bdb1..fcaf5902c3c223 100644 --- a/types/raven/raven-tests.ts +++ b/types/raven/raven-tests.ts @@ -31,7 +31,7 @@ new Raven.Client(dsn); try { throw new Error(); -} catch (e) { +} catch (e: any) { const eventId = Raven.captureException(e, (sendErr, eventId) => {}); } diff --git a/types/raygun4js/raygun4js-tests.ts b/types/raygun4js/raygun4js-tests.ts index be834332fe9ea3..c02ca53c753872 100644 --- a/types/raygun4js/raygun4js-tests.ts +++ b/types/raygun4js/raygun4js-tests.ts @@ -58,7 +58,7 @@ client.send(new Error("a error"), { some: "data" }, ["tag1", "tag2"]); try { throw new Error("oops"); -} catch (e) { +} catch (e: any) { client.send(e); } diff --git a/types/rclone.js/rclone.js-tests.ts b/types/rclone.js/rclone.js-tests.ts index 3c7f1a6dd5ed02..108ce4ea7d2bcd 100644 --- a/types/rclone.js/rclone.js-tests.ts +++ b/types/rclone.js/rclone.js-tests.ts @@ -20,7 +20,7 @@ async function usingRclonePromiseAPI() { try { const response = await rclonePromise.ls(rcloneRemoteName, rcloneConfigOptions); console.log(response.toString()); - } catch (error) { + } catch (error: any) { console.log(error.toString()); } } diff --git a/types/rdfjs__fetch-lite/rdfjs__fetch-lite-tests.ts b/types/rdfjs__fetch-lite/rdfjs__fetch-lite-tests.ts index f619dc08743bae..69ca7095035be4 100644 --- a/types/rdfjs__fetch-lite/rdfjs__fetch-lite-tests.ts +++ b/types/rdfjs__fetch-lite/rdfjs__fetch-lite-tests.ts @@ -95,7 +95,7 @@ async function environmentDatasetFetch(): Promise { dataset(): TestDataset { return {}; } - exports: ["dataset"]; + exports: ["dataset"] = ["dataset"]; } const environmentTest = new Environment([ FetchFactory, diff --git a/types/react-alert/v2/react-alert-tests.tsx b/types/react-alert/v2/react-alert-tests.tsx index 78a88ada322693..e4ba75857fb3cc 100644 --- a/types/react-alert/v2/react-alert-tests.tsx +++ b/types/react-alert/v2/react-alert-tests.tsx @@ -3,7 +3,7 @@ import * as React from "react"; import AlertContainer, { AlertContainerProps } from "react-alert"; export default class App extends React.Component { - msg: AlertContainer; + msg!: AlertContainer; alertOptions: AlertContainerProps = { offset: 14, diff --git a/types/react-avatar-editor/react-avatar-editor-tests.tsx b/types/react-avatar-editor/react-avatar-editor-tests.tsx index ae4258cc4a6460..f5642f85437cb0 100644 --- a/types/react-avatar-editor/react-avatar-editor-tests.tsx +++ b/types/react-avatar-editor/react-avatar-editor-tests.tsx @@ -16,7 +16,7 @@ const imageState: ImageState = { }; class AvatarEditorTest extends React.Component { - avatar: AvatarEditor; + avatar!: AvatarEditor; test() { const getImage: HTMLCanvasElement = this.avatar.getImage(); diff --git a/types/react-dom/test/canary-tests.tsx b/types/react-dom/test/canary-tests.tsx index d44db301a7160b..22ca8ed555c643 100644 --- a/types/react-dom/test/canary-tests.tsx +++ b/types/react-dom/test/canary-tests.tsx @@ -99,3 +99,12 @@ function fragmentRefTest() {
; } + +function formrelatedEventTests() { +
{ + // $ExpectType HTMLElement | null + event.submitter; + }} + />; +} diff --git a/types/react-dom/test/react-dom-tests.tsx b/types/react-dom/test/react-dom-tests.tsx index f5e92498ef3589..1184d2e084705e 100644 --- a/types/react-dom/test/react-dom-tests.tsx +++ b/types/react-dom/test/react-dom-tests.tsx @@ -756,7 +756,7 @@ function formrelatedEventTests() { { - // @ts-expect-error -- submitter is not yet exposed by React + // Only passes because program includes React Canary types event.submitter; // $ExpectType EventTarget & HTMLFormElement event.target; diff --git a/types/react-image-gallery/react-image-gallery-tests.tsx b/types/react-image-gallery/react-image-gallery-tests.tsx index de4f07d9ce544a..999c92b9e6c9fb 100644 --- a/types/react-image-gallery/react-image-gallery-tests.tsx +++ b/types/react-image-gallery/react-image-gallery-tests.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import ReactImageGallery, { ReactImageGalleryItem, ReactImageGalleryProps } from "react-image-gallery"; class ImageGallery extends React.Component { - private gallery: ReactImageGallery | null; + private gallery!: ReactImageGallery | null; onBeforeSlide(index: number) { const message = `onBeforeSlide ${index}`; diff --git a/types/react-input-autosize/react-input-autosize-tests.tsx b/types/react-input-autosize/react-input-autosize-tests.tsx index 3e0c5e5b3451e4..84282300efc47f 100644 --- a/types/react-input-autosize/react-input-autosize-tests.tsx +++ b/types/react-input-autosize/react-input-autosize-tests.tsx @@ -3,7 +3,7 @@ import AutosizeInput, { AutosizeInputProps } from "react-input-autosize"; class Test extends React.Component { input: HTMLInputElement | null = null; - auto: AutosizeInput; + auto!: AutosizeInput; inputRef = (ref: HTMLInputElement | null) => { this.input = ref; diff --git a/types/react-map-gl/react-map-gl-tests.tsx b/types/react-map-gl/react-map-gl-tests.tsx index c89ef2b65906af..557c5a3d2af5fa 100644 --- a/types/react-map-gl/react-map-gl-tests.tsx +++ b/types/react-map-gl/react-map-gl-tests.tsx @@ -49,8 +49,8 @@ class MyMap extends React.Component<{}, State> { minPitch: 0, }, }; - private mapboxMap: MapboxGL.Map; - private map: InteractiveMap; + private mapboxMap!: MapboxGL.Map; + private map!: InteractiveMap; render() { return ( diff --git a/types/react-motion/react-motion-tests.tsx b/types/react-motion/react-motion-tests.tsx index effbb3c3a95d84..52515d47ef882b 100644 --- a/types/react-motion/react-motion-tests.tsx +++ b/types/react-motion/react-motion-tests.tsx @@ -79,10 +79,11 @@ class StaggeredTest extends React.Component { ); } - getStyles(prevInterpolatedStyles: PlainStyle[]): Style[] { - return prevInterpolatedStyles.map((prevStyle, index) => { + getStyles(prevInterpolatedStyles?: PlainStyle[]): Style[] { + const styles = prevInterpolatedStyles ?? []; + return styles.map((prevStyle, index) => { const style: Style = {}; - style["h"] = (index === 0) ? spring(100) : spring(prevInterpolatedStyles[index - 1]["h"]); + style["h"] = (index === 0) ? spring(100) : spring(styles[index - 1]["h"]); return style; }); } diff --git a/types/react-native-charts-wrapper/react-native-charts-wrapper-tests.tsx b/types/react-native-charts-wrapper/react-native-charts-wrapper-tests.tsx index 3b8591f81ea413..6edd9f50917219 100644 --- a/types/react-native-charts-wrapper/react-native-charts-wrapper-tests.tsx +++ b/types/react-native-charts-wrapper/react-native-charts-wrapper-tests.tsx @@ -10,6 +10,7 @@ import { HorizontalBarChart, LineChart, PieChart, + PieChartSelectEvent, } from "react-native-charts-wrapper"; const styles = StyleSheet.create({ @@ -753,7 +754,7 @@ class Combined extends React.Component { } class PieChartScreen extends React.Component { - handleSelect(event: ChartSelectEvent) { + handleSelect(event: PieChartSelectEvent) { console.log(event.nativeEvent); } diff --git a/types/react-native-datepicker/react-native-datepicker-tests.tsx b/types/react-native-datepicker/react-native-datepicker-tests.tsx index 44860d2ad2bab0..5170dbfebde4e5 100644 --- a/types/react-native-datepicker/react-native-datepicker-tests.tsx +++ b/types/react-native-datepicker/react-native-datepicker-tests.tsx @@ -6,7 +6,7 @@ interface MyDatePickerState { } export default class MyDatePicker extends React.Component<{}, MyDatePickerState> { - datepicker: DatePicker | null; + datepicker!: DatePicker | null; state = { date: "2016-05-15" }; diff --git a/types/react-native-google-signin/react-native-google-signin-tests.tsx b/types/react-native-google-signin/react-native-google-signin-tests.tsx index dde30a8408d646..d96fa70c54dacd 100644 --- a/types/react-native-google-signin/react-native-google-signin-tests.tsx +++ b/types/react-native-google-signin/react-native-google-signin-tests.tsx @@ -20,7 +20,7 @@ export default class Signin extends React.Component<{}, State> { let user; try { user = await GoogleSignin.signInSilently(); - } catch (error) { + } catch (error: any) { if (error.code === statusCodes.SIGN_IN_REQUIRED) { user = await GoogleSignin.signIn(); } diff --git a/types/react-native-material-dropdown/react-native-material-dropdown-tests.tsx b/types/react-native-material-dropdown/react-native-material-dropdown-tests.tsx index 1fcb363b781e2c..95d8db2b155798 100644 --- a/types/react-native-material-dropdown/react-native-material-dropdown-tests.tsx +++ b/types/react-native-material-dropdown/react-native-material-dropdown-tests.tsx @@ -7,9 +7,9 @@ interface DropdownTestProps { } class DropdownTest extends React.Component { - private layout: LayoutRectangle; - private isFocused: boolean; - private curText: string; + private layout!: LayoutRectangle; + private isFocused!: boolean; + private curText!: string; render(): React.JSX.Element { const dropdownData: DropDownData[] = [ diff --git a/types/react-native-modalbox/react-native-modalbox-tests.tsx b/types/react-native-modalbox/react-native-modalbox-tests.tsx index 0258cfb5c8b2c3..6ab54d416b8b7a 100644 --- a/types/react-native-modalbox/react-native-modalbox-tests.tsx +++ b/types/react-native-modalbox/react-native-modalbox-tests.tsx @@ -15,7 +15,7 @@ class Example extends React.Component<{}, State> { modal1: Modal | null = null; modal2: Modal | null = null; modal3: Modal | null = null; - modal4: Modal; + modal4!: Modal; modal6: Modal | null = null; state = { diff --git a/types/react-native-modals/react-native-modals-tests.tsx b/types/react-native-modals/react-native-modals-tests.tsx index 2ed49d4dbbb01c..42c9a27b925866 100644 --- a/types/react-native-modals/react-native-modals-tests.tsx +++ b/types/react-native-modals/react-native-modals-tests.tsx @@ -24,9 +24,9 @@ class ImperativeUsageTest extends React.Component { }; } - fadingPopupModal: Modal; - scalingPopupModal: Modal; - slidingPopupModal: Modal; + fadingPopupModal!: Modal; + scalingPopupModal!: Modal; + slidingPopupModal!: Modal; componentDidMount() { this.fadingPopupModal = ModalPortal.show(, { diff --git a/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx b/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx index 5d88ae544da3a6..408b0ff51e73ed 100644 --- a/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx +++ b/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx @@ -15,9 +15,9 @@ const scaleAnimation = new ScaleAnimation(); const fadeAnimation = new FadeAnimation({ animationDuration: 150 }); class Test extends React.Component { - fadingPopupDialog: Dialog | null; - scalingPopupDialog: Dialog | null; - slidingPopupDialog: Dialog | null; + fadingPopupDialog!: Dialog | null; + scalingPopupDialog!: Dialog | null; + slidingPopupDialog!: Dialog | null; showPopupDialog(popupDialog: Dialog | null) { if (popupDialog !== null) { diff --git a/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx b/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx index 574829fe183627..aac853b4683256 100644 --- a/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx +++ b/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx @@ -11,7 +11,7 @@ declare const object: object; declare const func: () => void; class Test extends React.Component { - ref: SmoothScrollbar | null; + ref!: SmoothScrollbar | null; componentDidMount() { if (this.ref) { diff --git a/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx b/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx index 983c4f9ff11acd..a567906f43a59f 100644 --- a/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx +++ b/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx @@ -18,7 +18,7 @@ interface State { } class Example1 extends React.Component<{}, State> { - Viewer: ReactSVGPanZoom | null; + Viewer!: ReactSVGPanZoom | null; constructor(props: Props) { super(props); diff --git a/types/react-virtualized/react-virtualized-tests.tsx b/types/react-virtualized/react-virtualized-tests.tsx index c55a37c99de6fc..5362cea2bbbef7 100644 --- a/types/react-virtualized/react-virtualized-tests.tsx +++ b/types/react-virtualized/react-virtualized-tests.tsx @@ -1027,8 +1027,8 @@ export class GridExample2 extends PureComponent { _width = 0; _height = 0; _scrollTop?: number | undefined; - _cellPositioner: Positioner; - _masonry: Masonry; + _cellPositioner!: Positioner; + _masonry!: Masonry; constructor(props: any) { super(props); @@ -1656,7 +1656,7 @@ export class DynamicHeightTableColumnExample extends PureComponent { export class WindowScrollerExample extends PureComponent<{}, any> { context: any; contextType: any; - _windowScroller: WindowScroller; + _windowScroller!: WindowScroller; state = { showHeaderText: true, }; diff --git a/types/react/canary.d.ts b/types/react/canary.d.ts index b1cac75e162f5d..e9a4312fcb27cb 100644 --- a/types/react/canary.d.ts +++ b/types/react/canary.d.ts @@ -30,6 +30,8 @@ export {}; declare const UNDEFINED_VOID_ONLY: unique symbol; type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never }; +type NativeSubmitEvent = SubmitEvent; + declare module "." { export function unstable_useCacheRefresh(): () => void; @@ -117,4 +119,11 @@ declare module "." { export interface FragmentProps { ref?: Ref | undefined; } + + interface SubmitEvent extends SyntheticEvent { + /** + * Only available in react@canary + */ + submitter: HTMLElement | null; + } } diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 40620b451199f7..de2143c01ea47e 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -2158,7 +2158,7 @@ declare namespace React { } interface SubmitEvent extends SyntheticEvent { - // Currently not exposed by Reat + // `submitter` is available in react@canary // submitter: HTMLElement | null; // SubmitEvents are always targetted at HTMLFormElements. target: EventTarget & HTMLFormElement; @@ -3525,7 +3525,7 @@ declare namespace React { value?: string | readonly string[] | number | undefined; wrap?: string | undefined; - // No other element dispatching change events can be nested in a + // No other element dispatching change events can be nested in a