remove list formatting

This commit is contained in:
Duc Anh Phi 2023-08-22 17:52:48 +02:00
parent c7389ffdf0
commit 4742409b5b

View file

@ -801,13 +801,10 @@ function unique<T>(values: T[]): T[] {
return Array.from(new Set(values));
}
const andFormatter = new Intl.ListFormat('en', {style: 'long', type: 'conjunction'});
const orFormatter = new Intl.ListFormat('en', {style: 'long', type: 'disjunction'});
function typeErrorMessageMultipleValues(expectedType: AssertionTypeDescription | AssertionTypeDescription[], values: unknown[]): string {
const uniqueExpectedTypes = unique((isArray(expectedType) ? expectedType : [expectedType]).map(value => `\`${value}\``));
const uniqueValueTypes = unique(values.map(value => `\`${is(value)}\``));
return `Expected values which are ${orFormatter.format(uniqueExpectedTypes)}. Received values of type${uniqueValueTypes.length > 1 ? 's' : ''} ${andFormatter.format(uniqueValueTypes)}.`;
return `Expected values which are ${uniqueExpectedTypes.join(", ")}. Received values of type${uniqueValueTypes.length > 1 ? 's' : ''} ${uniqueValueTypes.join(", ")}.`;
}
// Type assertions have to be declared with an explicit type.