diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 60a2643fb45ef1..8d8b006fb6c690 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -108,7 +108,7 @@ /types/alexa-voice-service/ @dolanmiu /types/algebra.js/ @CaselIT /types/ali-app/ @taoqf -/types/ali-oss/ @ptrdu @StarHeartHunt +/types/ali-oss/ @ptrdu @StarHeartHunt @cnjsstong /types/alicloud__log/ @RuixeWolf /types/align-text/ @claasahl /types/alipayjssdk/ @shlyren @@ -2008,7 +2008,7 @@ /types/ez-plus/ @AndersonFriaca /types/ezuikit-js/ @daiwanxing /types/f1/ @neolwc -/types/fabric/ @oklemencic @joewashear007 @mrand01 @NotWoods @bmartinson @RogerioTeixeira @BradleyHill @bmkrol823 @glenngartner @codertx @mike667 @nataliemarleny @oxwazz +/types/fabric/ @oklemencic @joewashear007 @NotWoods @bmartinson @RogerioTeixeira @BradleyHill @bmkrol823 @glenngartner @codertx @mike667 @nataliemarleny @oxwazz /types/facebook-instant-games/ @menushka @oyvindjam @doterax /types/facebook-js-sdk/ @amritk @mahmoudzohdi @fluidsonic @bengry /types/facebook-locales/ @CvX @@ -2035,7 +2035,6 @@ /types/fast-als/ @elias-fauser /types/fast-astar/ @shezard /types/fast-chunk-string/ @yoursunny -/types/fast-crc32c/ @naeemy /types/fast-decode-uri-component/ @huseeiin /types/fast-fifo/ @achingbrain /types/fast-html-parser/ @rollercodester @@ -3365,7 +3364,6 @@ /types/iniparser/ @chrootsu /types/init-package-json/ @kfarnung /types/initrc/ @Soldy -/types/injectpromise/ @naeemy /types/ink-big-text/ @aaronleopold /types/ink-box/ @omjadas /types/ink-divider/ @omjadas @@ -3968,7 +3966,7 @@ /types/karma-spec-reporter/ @peterblazejewicz /types/karma-summary-reporter/ @peterblazejewicz @sth /types/karma-webpack/ @mtraynham -/types/katex/ @mrand01 @knguyen0125 @dreamerblue @s-weigand @sapphi-red @Stefaans +/types/katex/ @knguyen0125 @dreamerblue @s-weigand @sapphi-red @Stefaans /types/kavenegar/ @nimaebra /types/kbm-robot/ @usama8800 /types/kcors/ @Xstoudi @@ -5181,7 +5179,6 @@ /types/node-ipc/ @arvitaly @gjurgens /types/node-isbn/ @peterblazejewicz /types/node-jose/ @nadunindunil -/types/node-jsfl-runner/ @mrand01 /types/node-json-logger/ @from20020516 /types/node-json-transform/ @ymaheshwari1 /types/node-kmeans/ @aquine-kujaruk @@ -5558,7 +5555,7 @@ /types/passport-deezer/ @nyo /types/passport-discord/ @kzay @almeidx /types/passport-facebook/ @staticfunction @lucasmacosta -/types/passport-facebook-token/ @rmartone @mrand01 +/types/passport-facebook-token/ @rmartone /types/passport-fido2-webauthn/ @benhchoi /types/passport-github/ @yasupeke /types/passport-github2/ @yasupeke @mthmulders @codepunkt @ivan94 @@ -6258,7 +6255,6 @@ /types/react-google-recaptcha/v0/ @KoalaHuman @tomsturge /types/react-google-recaptcha-enterprise/ @KsAkira10 /types/react-gravatar/ @invliD -/types/react-grid-layout/ @abirkholz @alitaheri @ZheyangSong @andrewhathaway @manav-m @al-fyodorov /types/react-gtm-module/ @marcveens /types/react-hamburger-menu/ @grzesie2k /types/react-hammerjs/ @jsonunger @cecchi @@ -6445,7 +6441,6 @@ /types/react-native-referrer/ @christianchown /types/react-native-responsive-image/ @dimameshcharakou /types/react-native-rss-parser/ @emilianoLeite -/types/react-native-safari-view/ @mrand01 /types/react-native-scaled-image/ @Jaeger25 /types/react-native-scrollable-tab-view/ @egorshulga @ydostyle /types/react-native-settings-list/ @MrLuje @@ -7060,7 +7055,6 @@ /types/schwifty/ @ozum @timcosta /types/scoped-http-client/ @mattvperry @rianadon /types/scorm-browser/ @CookieCookson -/types/scrambo/ @padarom /types/scratch-env/ @Richienb /types/screenshot-desktop/ @usama8800 /types/screeps/ @NhanHo @bryanbecker @resir014 @Arcath @dmarcuse @pyrodogg @kotarou @DiamondMofeng @@ -7453,7 +7447,6 @@ /types/ssdeep/ @atd-schubert /types/ssdeep.js/ @JPBM135 /types/sse/ @yutak23 -/types/sse4_crc32/ @naeemy /types/ssh-key-decrypt/ @BendingBender /types/ssh2/ @tkQubo @rbuckton @wrboyce @hengkx @bragle @LucianBuzzo @dhensby /types/ssh2-sftp-client/ @igrayson @ascariandrea @kartik2406 @viamuli @gbhmt @builtbylane @loru88 @hengkx @candyapplecorn @tsop14 @@ -7730,7 +7723,6 @@ /types/tdigest/ @BendingBender /types/teddy/ @lannonbr /types/tedious-connection-pool/ @sandorfr -/types/teen_process/ @NotWoods /types/telebot/ @mariotsi @martin-badin /types/telegram-mini-app/ @dartweider2000 /types/telegram-web-app/ @KnorpelSenf @MKRhere @deptyped @sidorko diff --git a/types/d3-shape/d3-shape-tests.ts b/types/d3-shape/d3-shape-tests.ts index 01cb912aab54d9..ab11307dab0e10 100644 --- a/types/d3-shape/d3-shape-tests.ts +++ b/types/d3-shape/d3-shape-tests.ts @@ -1525,7 +1525,7 @@ defaultStack = defaultStack.offset(null); overlyComplicatedStack = overlyComplicatedStack.offset(d3Shape.stackOffsetWiggle); -let offsetStackDatumSeries: (series: d3Shape.Series, order: number[]) => void; +let offsetStackDatumSeries: (series: d3Shape.Series[], order: number[]) => void; offsetStackDatumSeries = overlyComplicatedStack.offset(); // Use stack generator ============================================================ @@ -1567,8 +1567,8 @@ order = d3Shape.stackOrderReverse(seriesAnyAny); // Test stack offsets =============================================================== -d3Shape.stackOffsetExpand(seriesAnyAny, order); -d3Shape.stackOffsetDiverging(seriesAnyAny, order); -d3Shape.stackOffsetNone(seriesAnyAny, order); -d3Shape.stackOffsetSilhouette(seriesAnyAny, order); -d3Shape.stackOffsetWiggle(seriesAnyAny, order); +d3Shape.stackOffsetExpand(seriesArray, order); +d3Shape.stackOffsetDiverging(seriesArray, order); +d3Shape.stackOffsetNone(seriesArray, order); +d3Shape.stackOffsetSilhouette(seriesArray, order); +d3Shape.stackOffsetWiggle(seriesArray, order); diff --git a/types/d3-shape/index.d.ts b/types/d3-shape/index.d.ts index 1ef05584c3c1f4..d596f65ce47e8b 100644 --- a/types/d3-shape/index.d.ts +++ b/types/d3-shape/index.d.ts @@ -2539,7 +2539,7 @@ export interface Stack { /** * Returns the current offset accessor, which defaults to stackOffsetNone; this uses a zero baseline. */ - offset(): (series: Series, order: number[]) => void; + offset(): (series: Series[], order: number[]) => void; /** * Reset the offset to use stackOffsetNone; this uses a zero baseline. * @@ -2552,7 +2552,7 @@ export interface Stack { * @param offset A function which is passed the generated series array and the order index array; * it is then responsible for updating the lower and upper values in the series array. */ - offset(offset: (series: Series, order: number[]) => void): this; + offset(offset: (series: Series[], order: number[]) => void): this; } /** @@ -2641,40 +2641,40 @@ export function stackOrderReverse(series: Series): number[]; /** * Applies a zero baseline and normalizes the values for each point such that the topline is always one. * - * @param series A series generated by a stack generator. + * @param series A series array generated by a stack generator. * @param order An array of numeric indexes representing the stack order. */ -export function stackOffsetExpand(series: Series, order: Iterable): void; +export function stackOffsetExpand(series: Series[], order: Iterable): void; /** * Positive values are stacked above zero, while negative values are stacked below zero. * - * @param series A series generated by a stack generator. + * @param series A series array generated by a stack generator. * @param order An array of numeric indexes representing the stack order. */ -export function stackOffsetDiverging(series: Series, order: Iterable): void; +export function stackOffsetDiverging(series: Series[], order: Iterable): void; /** * Applies a zero baseline. * - * @param series A series generated by a stack generator. + * @param series A series array generated by a stack generator. * @param order An array of numeric indexes representing the stack order. */ -export function stackOffsetNone(series: Series, order: Iterable): void; +export function stackOffsetNone(series: Series[], order: Iterable): void; /** * Shifts the baseline down such that the center of the streamgraph is always at zero. * - * @param series A series generated by a stack generator. + * @param series A series array generated by a stack generator. * @param order An array of numeric indexes representing the stack order. */ -export function stackOffsetSilhouette(series: Series, order: Iterable): void; +export function stackOffsetSilhouette(series: Series[], order: Iterable): void; /** * Shifts the baseline so as to minimize the weighted wiggle of layers. This offset is recommended for streamgraphs in conjunction with the inside-out order. * See Stacked Graphs—Geometry & Aesthetics by Bryon & Wattenberg for more information. * - * @param series A series generated by a stack generator. + * @param series A series array generated by a stack generator. * @param order An array of numeric indexes representing the stack order. */ -export function stackOffsetWiggle(series: Series, order: Iterable): void; +export function stackOffsetWiggle(series: Series[], order: Iterable): void; diff --git a/types/jest-image-snapshot/index.d.ts b/types/jest-image-snapshot/index.d.ts index 1b2d7a0d05f430..25fcb811bb6761 100644 --- a/types/jest-image-snapshot/index.d.ts +++ b/types/jest-image-snapshot/index.d.ts @@ -134,7 +134,10 @@ export interface MatchImageSnapshotOptions { * import { toMatchImageSnapshot } from 'jest-image-snapshot'; * expect.extend({ toMatchImageSnapshot }); */ -export function toMatchImageSnapshot(options?: MatchImageSnapshotOptions): { message(): string; pass: boolean }; +export function toMatchImageSnapshot( + received: Buffer, + options?: MatchImageSnapshotOptions, +): { message(): string; pass: boolean }; /** * Configurable function that can be passed to jest's expect.extend. @@ -145,7 +148,7 @@ export function toMatchImageSnapshot(options?: MatchImageSnapshotOptions): { mes */ export function configureToMatchImageSnapshot( options: MatchImageSnapshotOptions, -): () => { message(): string; pass: boolean }; +): (received: Buffer, options?: MatchImageSnapshotOptions) => { message(): string; pass: boolean }; /** * Mutates original state with new state diff --git a/types/jest-image-snapshot/jest-image-snapshot-tests.ts b/types/jest-image-snapshot/jest-image-snapshot-tests.ts index 04063e75d03c82..fda12b913f48ef 100644 --- a/types/jest-image-snapshot/jest-image-snapshot-tests.ts +++ b/types/jest-image-snapshot/jest-image-snapshot-tests.ts @@ -4,14 +4,24 @@ import { toMatchImageSnapshot, updateSnapshotState, } from "jest-image-snapshot"; +import sharp from "sharp"; -it("should be able to use toMatchImageSnapshot in a test", () => { +it("should be able to use toMatchImageSnapshot in a test", async () => { expect.extend({ toMatchImageSnapshot }); - expect(400).toMatchImageSnapshot(); + expect( + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + ).toMatchImageSnapshot(); }); -it("should be able to use configureToMatchImageSnapshot in a test", () => { +it("should be able to use configureToMatchImageSnapshot in a test", async () => { const matchFn = configureToMatchImageSnapshot({ allowSizeMismatch: true, noColors: true, @@ -25,10 +35,19 @@ it("should be able to use configureToMatchImageSnapshot in a test", () => { }); expect.extend({ toMatchImageSnapshot: matchFn }); - expect("Me").toMatchImageSnapshot(); + expect( + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + ).toMatchImageSnapshot(); }); -it("Should be able to use configuration directly in toMatchImageSnapshot", () => { +it("Should be able to use configuration directly in toMatchImageSnapshot", async () => { expect.extend({ toMatchImageSnapshot }); const options: MatchImageSnapshotOptions = { @@ -52,23 +71,50 @@ it("Should be able to use configuration directly in toMatchImageSnapshot", () => failureThresholdType: "percent", }; - expect("Me").toMatchImageSnapshot(options); + expect( + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + ).toMatchImageSnapshot(options); }); -it("Should be able to use string as customSnapshotIdentifier", () => { +it("Should be able to use string as customSnapshotIdentifier", async () => { const options: MatchImageSnapshotOptions = { customSnapshotIdentifier: "string identifier", }; - expect("Me").toMatchImageSnapshot(options); + expect( + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + ).toMatchImageSnapshot(options); }); -it("Should be able to use callback as customSnapshotIdentifier", () => { +it("Should be able to use callback as customSnapshotIdentifier", async () => { const options: MatchImageSnapshotOptions = { customSnapshotIdentifier: () => "string identifier", }; - expect("Me").toMatchImageSnapshot(options); + expect( + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + ).toMatchImageSnapshot(options); }); it("mutates original state", () => { @@ -76,3 +122,40 @@ it("mutates original state", () => { updateSnapshotState(originalState, { another: "val" }); expect(originalState).toEqual({ some: "value", another: "val" }); }); + +it("should be able to use toMatchImageSnapshot without expect", async () => { + const result = toMatchImageSnapshot.call( + expect.getState(), + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + { + allowSizeMismatch: true, + }, + ); + expect(result.pass).toEqual(true); +}); + +it("should be able to use configureToMatchImageSnapshot without expect", async () => { + const matchFn = configureToMatchImageSnapshot({ + allowSizeMismatch: true, + }); + + const result = matchFn.call( + expect.getState(), + await sharp({ + create: { + background: { b: 0, g: 255, r: 0 }, + channels: 3, + height: 48, + width: 48, + }, + }).png().toBuffer(), + ); + expect(result.pass).toEqual(true); +}); diff --git a/types/jest-image-snapshot/package.json b/types/jest-image-snapshot/package.json index 3f49a0683527d8..f069becaa9bf07 100644 --- a/types/jest-image-snapshot/package.json +++ b/types/jest-image-snapshot/package.json @@ -11,7 +11,8 @@ "ssim.js": "^3.1.1" }, "devDependencies": { - "@types/jest-image-snapshot": "workspace:." + "@types/jest-image-snapshot": "workspace:.", + "sharp": "*" }, "owners": [ { diff --git a/types/jest-image-snapshot/stubs/runtimeHooksPath.js b/types/jest-image-snapshot/stubs/runtimeHooksPath.js new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/types/jquery.validation/index.d.ts b/types/jquery.validation/index.d.ts index 3fc7e4d2303490..121bd0d5ab8b1e 100644 --- a/types/jquery.validation/index.d.ts +++ b/types/jquery.validation/index.d.ts @@ -50,7 +50,7 @@ declare namespace JQueryValidation { * * default: Places the error label after the invalid element */ - errorPlacement?(error: JQuery, element: JQuery): void; + errorPlacement?(this: Validator, error: JQuery, element: JQuery): void; /** * If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. * Avoid combination with focusInvalid. @@ -76,7 +76,7 @@ declare namespace JQueryValidation { * * default: Adds errorClass (see the option) to the element */ - highlight?(element: HTMLElement, errorClass: string, validClass: string): void; + highlight?(this: Validator, element: HTMLElement, errorClass: string, validClass: string): void; /** * Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is * accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. @@ -93,7 +93,7 @@ declare namespace JQueryValidation { * Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator * as the second. */ - invalidHandler?(event: JQueryEventObject, validator: Validator): void; + invalidHandler?(this: HTMLFormElement, event: JQueryEventObject, validator: Validator): void; /** * Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead * of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or @@ -154,12 +154,12 @@ declare namespace JQueryValidation { * be a single element when doing validation onblur/keyup. You can trigger (in addition to your own messages) the default * behaviour by calling this.defaultShowErrors(). */ - showErrors?(errorMap: ErrorDictionary, errorList: ErrorListItem[]): void; + showErrors?(this: Validator, errorMap: ErrorDictionary, errorList: ErrorListItem[]): void; /** * Callback for handling the actual submit when the form is valid. Gets the form and the event object. Replaces the default submit. * The right place to submit a form via Ajax after it is validated. */ - submitHandler?(form: HTMLFormElement, event?: JQueryEventObject): void; + submitHandler?(this: Validator, form: HTMLFormElement, event?: JQueryEventObject): void; /** * String or Function. If specified, the error label is displayed to show a valid element. If a String is given, it is added as * a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). @@ -171,7 +171,7 @@ declare namespace JQueryValidation { * * default: Removes the errorClass */ - unhighlight?(element: HTMLElement, errorClass: string, validClass: string): void; + unhighlight?(this: Validator, element: HTMLElement, errorClass: string, validClass: string): void; /** * This class is added to an element after it was validated and considered valid. * @@ -218,8 +218,8 @@ declare namespace JQueryValidation { */ addMethod( name: string, - method: (value: any, element: HTMLElement, params: any) => boolean, - message?: string | ((params: any, element: HTMLElement) => string), + method: (this: Validator, value: any, element: HTMLElement, params: any) => boolean, + message?: string | ((this: Validator, params: any, element: HTMLElement) => string), ): void; /** * Replaces {n} placeholders with arguments. @@ -240,6 +240,8 @@ declare namespace JQueryValidation { } interface Validator { + defaultShowErrors(): void; + element(element: string | JQuery): boolean; checkForm(): boolean; /** @@ -255,6 +257,9 @@ declare namespace JQueryValidation { * Returns the number of invalid fields. */ numberOfInvalids(): number; + + optional(element: HTMLElement): boolean; + /** * Resets the controlled form. */ diff --git a/types/jquery.validation/jquery.validation-tests.ts b/types/jquery.validation/jquery.validation-tests.ts index 7af287f18e7899..6b3492be7c7445 100644 --- a/types/jquery.validation/jquery.validation-tests.ts +++ b/types/jquery.validation/jquery.validation-tests.ts @@ -133,7 +133,7 @@ function test_validate() { }, }); $(".selector").validate({ - showErrors: (errorMap: JQueryValidation.ErrorDictionary, errorList: JQueryValidation.ErrorListItem[]) => { + showErrors(errorMap: JQueryValidation.ErrorDictionary, errorList: JQueryValidation.ErrorListItem[]) { $("#summary").html(`Your form contains ${this.numberOfInvalids()} errors, see details below.`); this.defaultShowErrors(); }, diff --git a/types/jquery.validation/tsconfig.json b/types/jquery.validation/tsconfig.json index e23cecefaf77e4..069d3da0d8342c 100644 --- a/types/jquery.validation/tsconfig.json +++ b/types/jquery.validation/tsconfig.json @@ -6,7 +6,7 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, + "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "types": [],