diff --git a/benchmark/package.json b/benchmark/package.json index 103e84da5f..55e73ca667 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -72,6 +72,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-6.5.3.tgz" + "typia": "../typia-6.5.4.tgz" } } \ No newline at end of file diff --git a/debug/features/intersection.ts b/debug/features/intersection.ts new file mode 100644 index 0000000000..067c27f4fd --- /dev/null +++ b/debug/features/intersection.ts @@ -0,0 +1,6 @@ +import typia from "typia"; + +type Art = `${string}art${string}`; +type Bar = `${string}bar${string}`; + +console.log(typia.createIs().toString()); diff --git a/debug/package.json b/debug/package.json index 5da4b7838b..c6ef3553d7 100644 --- a/debug/package.json +++ b/debug/package.json @@ -15,6 +15,6 @@ "typescript": "^5.4.2" }, "dependencies": { - "typia": "../typia-6.5.3-dev.20240720.tgz" + "typia": "../typia-6.5.4-dev.20240721.tgz" } } \ No newline at end of file diff --git a/errors/package.json b/errors/package.json index 4a9168bfe6..282a1efe9b 100644 --- a/errors/package.json +++ b/errors/package.json @@ -32,6 +32,6 @@ "typescript": "^5.3.2" }, "dependencies": { - "typia": "../typia-6.5.3.tgz" + "typia": "../typia-6.5.4.tgz" } } \ No newline at end of file diff --git a/errors/src/nonsensible/error_nonsensible_intersection.ts b/errors/src/nonsensible/error_nonsensible_intersection.ts new file mode 100644 index 0000000000..a5ed193825 --- /dev/null +++ b/errors/src/nonsensible/error_nonsensible_intersection.ts @@ -0,0 +1,6 @@ +import typia from "typia"; + +type Art = `${string}art${string}`; +type Bar = `${string}bar${string}`; + +typia.createIs(); diff --git a/package.json b/package.json index fc05b43c52..cca9a31b35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typia", - "version": "6.5.3", + "version": "6.5.4", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/typescript-json/package.json b/packages/typescript-json/package.json index 977d4c281a..9ff123bbfc 100644 --- a/packages/typescript-json/package.json +++ b/packages/typescript-json/package.json @@ -1,6 +1,6 @@ { "name": "typescript-json", - "version": "6.5.3", + "version": "6.5.4", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -63,7 +63,7 @@ }, "homepage": "https://typia.io", "dependencies": { - "typia": "6.5.3" + "typia": "6.5.4" }, "peerDependencies": { "typescript": ">=4.8.0 <5.6.0" diff --git a/src/factories/internal/metadata/iterate_metadata_intersection.ts b/src/factories/internal/metadata/iterate_metadata_intersection.ts index 20e0159ff5..19df54b1f5 100644 --- a/src/factories/internal/metadata/iterate_metadata_intersection.ts +++ b/src/factories/internal/metadata/iterate_metadata_intersection.ts @@ -27,7 +27,8 @@ export const iterate_metadata_intersection = explore: MetadataFactory.IExplore, ): boolean => { if (!type.isIntersection()) return false; - else if ( + if ( + // ONLY OBJECT TYPED INTERSECTION type.types.every( (child) => (child.getFlags() & ts.TypeFlags.Object) !== 0 && @@ -68,9 +69,18 @@ export const iterate_metadata_intersection = ); return true; } else if (children.every((c) => c.objects.length === c.size())) + // ONLY OBJECT TYPED INTERSECTION (DETAILED) return false; // VALIDATE EACH TYPES + const nonsensible = () => { + errors.push({ + name: children.map((c) => c.getName()).join(" & "), + explore: { ...explore }, + messages: ["nonsensible intersection"], + }); + return true; + }; const individuals: (readonly [Metadata, number])[] = children .map((child, i) => [child, i] as const) .filter( @@ -82,7 +92,7 @@ export const iterate_metadata_intersection = c.arrays.length === 1)) || c.templates.length === 1, ); - if (individuals.length !== 1) return false; + if (individuals.length !== 1) return nonsensible(); const objects: Metadata[] = children.filter( (c) => @@ -109,14 +119,8 @@ export const iterate_metadata_intersection = if ( atomics.size + constants.length + arrays.size + templates.length > 1 || individuals.length + objects.length !== children.length - ) { - errors.push({ - name: children.map((c) => c.getName()).join(" & "), - explore: { ...explore }, - messages: ["nonsensible intersection"], - }); - return true; - } + ) + return nonsensible(); // RE-GENERATE TYPE const target: "boolean" | "bigint" | "number" | "string" | "array" = diff --git a/test-esm/package.json b/test-esm/package.json index 6b3ec99024..e68a8a9a81 100644 --- a/test-esm/package.json +++ b/test-esm/package.json @@ -36,6 +36,6 @@ "typescript": "^5.4.5" }, "dependencies": { - "typia": "../typia-6.5.3.tgz" + "typia": "../typia-6.5.4.tgz" } } \ No newline at end of file diff --git a/test/package.json b/test/package.json index c836bb9ab6..1729ba3e75 100644 --- a/test/package.json +++ b/test/package.json @@ -51,6 +51,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-6.5.3.tgz" + "typia": "../typia-6.5.4.tgz" } } \ No newline at end of file diff --git a/website/package.json b/website/package.json index 71e9e6cfe5..d696ed83e3 100644 --- a/website/package.json +++ b/website/package.json @@ -37,7 +37,7 @@ "tgrid": "^1.0.2", "tstl": "^3.0.0", "typescript": "^5.5.3", - "typia": "^6.5.3" + "typia": "^6.5.4" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0",