From b7d7813c5deacde98bcb7a5e63104431b85c09eb Mon Sep 17 00:00:00 2001 From: Alex Povar <1074182+zvirja@users.noreply.github.com> Date: Wed, 9 Oct 2019 21:29:31 +0200 Subject: [PATCH] Require read-only testers for matchers util (#39009) --- types/jasmine/index.d.ts | 6 +++--- types/jasmine/jasmine-tests.ts | 6 +++--- types/jasmine/ts3.1/index.d.ts | 6 +++--- types/jasmine/ts3.1/jasmine-tests.ts | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/types/jasmine/index.d.ts b/types/jasmine/index.d.ts index 9feeda7b59..7ac197c9e1 100644 --- a/types/jasmine/index.d.ts +++ b/types/jasmine/index.d.ts @@ -327,7 +327,7 @@ declare namespace jasmine { negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult; } - type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher; + type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray) => CustomMatcher; interface CustomMatcherFactories { [index: string]: CustomMatcherFactory; @@ -339,8 +339,8 @@ declare namespace jasmine { } interface MatchersUtil { - equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean; - contains(haystack: ArrayLike | string, needle: any, customTesters?: CustomEqualityTester[]): boolean; + equals(a: any, b: any, customTesters?: ReadonlyArray): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: ReadonlyArray): boolean; buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string; } diff --git a/types/jasmine/jasmine-tests.ts b/types/jasmine/jasmine-tests.ts index 165b479c95..01413d84b9 100644 --- a/types/jasmine/jasmine-tests.ts +++ b/types/jasmine/jasmine-tests.ts @@ -917,10 +917,10 @@ describe("jasmine.any", () => { }); describe('custom asymmetry', function() { - const tester = { - asymmetricMatch: (actual: string) => { + const tester: jasmine.AsymmetricMatcher = { + asymmetricMatch: (actual: string, customTesters) => { const secondValue = actual.split(',')[1]; - return secondValue === 'bar'; + return jasmine.matchersUtil.equals(secondValue, 'bar', customTesters); }, }; diff --git a/types/jasmine/ts3.1/index.d.ts b/types/jasmine/ts3.1/index.d.ts index 96a2c9861f..d31eca1899 100644 --- a/types/jasmine/ts3.1/index.d.ts +++ b/types/jasmine/ts3.1/index.d.ts @@ -329,7 +329,7 @@ declare namespace jasmine { negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult; } - type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher; + type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray) => CustomMatcher; interface CustomMatcherFactories { [index: string]: CustomMatcherFactory; @@ -341,8 +341,8 @@ declare namespace jasmine { } interface MatchersUtil { - equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean; - contains(haystack: ArrayLike | string, needle: any, customTesters?: CustomEqualityTester[]): boolean; + equals(a: any, b: any, customTesters?: ReadonlyArray): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: ReadonlyArray): boolean; buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string; } diff --git a/types/jasmine/ts3.1/jasmine-tests.ts b/types/jasmine/ts3.1/jasmine-tests.ts index e84072b0eb..8002276514 100644 --- a/types/jasmine/ts3.1/jasmine-tests.ts +++ b/types/jasmine/ts3.1/jasmine-tests.ts @@ -917,10 +917,10 @@ describe("jasmine.any", () => { }); describe('custom asymmetry', function() { - const tester = { - asymmetricMatch: (actual: string) => { + const tester: jasmine.AsymmetricMatcher = { + asymmetricMatch: (actual: string, customTesters) => { const secondValue = actual.split(',')[1]; - return secondValue === 'bar'; + return jasmine.matchersUtil.equals(secondValue, 'bar', customTesters); }, };