From 4f4538c5534b27decfc83031638de72305271391 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 16 Feb 2022 12:26:08 +0100 Subject: [PATCH] chore: type printWithType more accurately (#12405) --- packages/jest-matcher-utils/src/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/jest-matcher-utils/src/index.ts b/packages/jest-matcher-utils/src/index.ts index cdbad1a6c79f..eb62f5197c26 100644 --- a/packages/jest-matcher-utils/src/index.ts +++ b/packages/jest-matcher-utils/src/index.ts @@ -136,11 +136,11 @@ export const printReceived = (object: unknown): string => export const printExpected = (value: unknown): string => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value))); -export const printWithType = ( - name: string, // 'Expected' or 'Received' - value: unknown, - print: (value: unknown) => string, // printExpected or printReceived -): string => { +export function printWithType( + name: string, + value: T, + print: (value: T) => string, +): string { const type = getType(value); const hasType = type !== 'null' && type !== 'undefined' @@ -148,7 +148,7 @@ export const printWithType = ( : ''; const hasValue = `${name} has value: ${print(value)}`; return hasType + hasValue; -}; +} export const ensureNoExpected = ( expected: unknown, @@ -511,8 +511,8 @@ export const matcherErrorMessage = ( // Old format: matcher name has dim color export const matcherHint = ( matcherName: string, - received: string = 'received', - expected: string = 'expected', + received = 'received', + expected = 'expected', options: MatcherHintOptions = {}, ): string => { const {