Skip to content

Commit

Permalink
More safe escaping on intersection type diagnoser
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Nov 27, 2024
1 parent 953d3b8 commit faa9230
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "7.0.0-dev.20241127-3",
"version": "7.0.0-dev.20241127-4",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
20 changes: 13 additions & 7 deletions src/factories/internal/metadata/iterate_metadata_intersection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ export const iterate_metadata_intersection = (
intersected: false,
}),
);

// ERROR OR ANY TYPE CASE
const escape = () => {
Object.assign(props.collection, commit);
return false;
};
if (fakeErrors.length) {
props.errors.push(...fakeErrors);
return true;
} else if (children.length === 0) return false;
else if (children.some((m) => m.size() === 0)) return false;
} else if (children.length === 0) return escape();
else if (children.some((m) => m.any === true || m.size() === 0))
return escape();

// PREPARE MEATDATAS AND TAGS
const indexes: number[] = [];
Expand Down Expand Up @@ -78,15 +85,14 @@ export const iterate_metadata_intersection = (
messages: ["type tag cannot be standalone"],
});
return true;
} else return false;
} else return escape();
// ONLY OBJECTS CASE
else if (
metadatas.every((m) => m.objects.length === 1) &&
tagObjects.length === 0
) {
Object.assign(props.collection, commit);
return false;
} else if (metadatas.length !== 1) {
)
return escape();
else if (metadatas.length !== 1) {
const indexes: number[] = metadatas
.map((m, i) =>
m.size() === 1 &&
Expand Down

0 comments on commit faa9230

Please sign in to comment.