Skip to content

Commit 36d3bf4

Browse files
committed
fixed the issue
1 parent b3324da commit 36d3bf4

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

src/core/friendly_errors/param_validator.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,16 @@ function validateParams(p5, fn, lifecycles) {
464464
}
465465
});
466466

467-
// If we have both number type and Infinity literal errors, remove the "constant" message
468-
// because "number" already covers Infinity/-Infinity
469-
if (hasNumberType && infinityLiteralErrors > 0) {
470-
expectedTypes.delete('constant (please refer to documentation for allowed values)');
467+
// If the union contains only number and Infinity/-Infinity literals, treat as 'number'
468+
if (hasNumberType) {
469+
const typesArr = Array.from(expectedTypes);
470+
const onlyNumberAndInfinity = typesArr.every(t => {
471+
return t === 'number' || t === 'constant (please refer to documentation for allowed values)';
472+
}) && infinityLiteralErrors > 0;
473+
if (onlyNumberAndInfinity) {
474+
expectedTypes.clear();
475+
expectedTypes.add('number');
476+
}
471477
}
472478

473479
if (expectedTypes.size > 0) {
503 Bytes
Loading
-1.43 KB
Loading
-11 Bytes
Loading

test/unit/visual/visualTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ export function visualTest(
473473
const diffFilename = `../actual-screenshots/${flatName}-${i.toString().padStart(3, '0')}-diff.png`;
474474
writeImageFile(diffFilename, toBase64(result.diff));
475475
throw new Error(
476-
`Screenshots do not match! Expected:\n${toBase64(expected[i])}\n\nReceived:\n${toBase64(actual[i])}\n\nDiff:\n${toBase64(result.diff)}\n\n` +
476+
`Screens npx vitest test/unit/visual/visualTest.js --run npx vitest test/unit/visual/visualTest.js --runhots do not match! Expected:\n${toBase64(expected[i])}\n\nReceived:\n${toBase64(actual[i])}\n\nDiff:\n${toBase64(result.diff)}\n\n` +
477477
'If this is unexpected, paste these URLs into your browser to inspect them.\n\n' +
478478
`If this change is expected, please delete the screenshots/${name} folder and run tests again to generate a new screenshot.`
479479
);

vitest.workspace.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default defineWorkspace([
2929
exclude: [
3030
'./test/unit/spec.js',
3131
'./test/unit/assets/**/*',
32-
'./test/unit/visual/visualTest.js',
3332
'./test/types/**/*'
3433
],
3534
testTimeout: 1000,

0 commit comments

Comments
 (0)