From 73c8de1a0a9f9202c456aff917312ee18b906b4e Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Fri, 29 Sep 2023 14:27:57 -0700 Subject: [PATCH] Polyfill: Refine valueOf exception message (again) Continue where #2667 left off by further clarifying this error message and fixing a mistake where `+foo` was treated as a string coercion, not the number coercion that it is. --- polyfill/lib/ecmascript.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index f7622d99c4..0c0feaf285 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -5866,9 +5866,10 @@ export function ValueOfThrows(constructorName) { throw new TypeError( 'Do not use built-in arithmetic operators with Temporal objects. ' + `When comparing, use ${compareCode}, not obj1 > obj2. ` + - "When coercing to strings, use obj.toString() or String(obj), not +obj nor '' + obj. " + - 'When concatenating with strings, use str.concat(obj) or `${str}${obj}`, not str + obj. ' + - 'In React, call obj.toString() before rendering a Temporal object.' + "When coercing to strings, use `${obj}` or String(obj), not '' + obj. " + + 'When coercing to numbers, use properties or methods of the object, not `+obj`. ' + + 'When concatenating with strings, use `${str}${obj}` or str.concat(obj), not str + obj. ' + + 'In React, coerce to a string before rendering a Temporal object.' ); }