From 1235aa273ec404f20eab007f17a40325cd8266cb Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sat, 27 Jul 2024 02:14:37 +0900 Subject: [PATCH] Fix #1179: tuple type in dynamic object case. --- benchmark/package.json | 2 +- debug/build.js | 34 +++++++++++++++ debug/features/array.ts | 22 ---------- debug/features/camel.ts | 43 ------------------- debug/features/clone.ts | 38 ---------------- debug/features/description.ts | 34 --------------- debug/features/discriminator.ts | 43 ------------------- debug/features/dynamic.ts | 11 ----- debug/features/functional.ts | 13 ------ debug/features/intersection.ts | 6 --- debug/features/join.ts | 9 ++++ debug/features/name.ts | 19 -------- debug/features/openapi.ts | 26 ----------- debug/features/prisma.ts | 7 --- debug/features/protobuf.ts | 6 --- debug/features/random.ts | 8 ---- debug/features/record.ts | 5 --- debug/features/recursive.ts | 6 --- debug/features/resolved.ts | 9 ---- debug/features/schema.ts | 11 ----- debug/features/set.ts | 21 --------- debug/features/template.ts | 37 ---------------- debug/features/type.ts | 12 ------ debug/features/unique.ts | 12 ------ debug/package.json | 5 ++- errors/package.json | 2 +- package.json | 2 +- packages/typescript-json/package.json | 4 +- src/programmers/CheckerProgrammer.ts | 3 +- src/programmers/internal/postfix_of_tuple.ts | 2 + .../json/JsonStringifyProgrammer.ts | 3 +- src/programmers/misc/MiscCloneProgrammer.ts | 3 +- src/programmers/misc/MiscPruneProgrammer.ts | 3 +- .../notations/NotationGeneralProgrammer.ts | 3 +- test-esm/package.json | 2 +- test/package.json | 2 +- ...issue_1179_tuple_type_in_dynamic_object.ts | 14 ++++++ website/package.json | 4 +- 38 files changed, 81 insertions(+), 405 deletions(-) create mode 100644 debug/build.js delete mode 100644 debug/features/array.ts delete mode 100644 debug/features/camel.ts delete mode 100644 debug/features/clone.ts delete mode 100644 debug/features/description.ts delete mode 100644 debug/features/discriminator.ts delete mode 100644 debug/features/dynamic.ts delete mode 100644 debug/features/functional.ts delete mode 100644 debug/features/intersection.ts create mode 100644 debug/features/join.ts delete mode 100644 debug/features/name.ts delete mode 100644 debug/features/openapi.ts delete mode 100644 debug/features/prisma.ts delete mode 100644 debug/features/protobuf.ts delete mode 100644 debug/features/random.ts delete mode 100644 debug/features/record.ts delete mode 100644 debug/features/recursive.ts delete mode 100644 debug/features/resolved.ts delete mode 100644 debug/features/schema.ts delete mode 100644 debug/features/set.ts delete mode 100644 debug/features/template.ts delete mode 100644 debug/features/type.ts delete mode 100644 debug/features/unique.ts create mode 100644 src/programmers/internal/postfix_of_tuple.ts create mode 100644 test/src/features/issues/test_issue_1179_tuple_type_in_dynamic_object.ts diff --git a/benchmark/package.json b/benchmark/package.json index 55e73ca667..2467d15459 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.4.tgz" + "typia": "../typia-6.5.5.tgz" } } \ No newline at end of file diff --git a/debug/build.js b/debug/build.js new file mode 100644 index 0000000000..0cb6ba8e01 --- /dev/null +++ b/debug/build.js @@ -0,0 +1,34 @@ +const cp = require("child_process"); +const fs = require("fs"); +const supress = require("suppress-warnings"); + +const setup = () => { + const version = (() => { + cp.execSync("npm pack", { cwd: `${__dirname}/..` }); + const pack = JSON.parse( + fs.readFileSync(`${__dirname}/../package.json`, "utf8"), + ); + return pack.version; + })(); + const mine = JSON.parse(fs.readFileSync(`${__dirname}/package.json`, "utf8")); + + if (fs.existsSync(`${__dirname}/node_modules/typia`)) + cp.execSync("npm uninstall typia", { + cwd: __dirname, + stdio: "ignore", + }); + mine.dependencies.typia = `../typia-${version}.tgz`; + fs.writeFileSync(`${__dirname}/package.json`, JSON.stringify(mine, null, 2)); + cp.execSync("npm install", { cwd: __dirname, stdio: "ignore" }); +}; + +const execute = () => { + cp.execSync("npx rimraf bin && npx tsc", { + cwd: __dirname, + stdio: "inherit", + }); +}; + +supress([() => true]); +setup(); +execute(); diff --git a/debug/features/array.ts b/debug/features/array.ts deleted file mode 100644 index 8401992903..0000000000 --- a/debug/features/array.ts +++ /dev/null @@ -1,22 +0,0 @@ -import typia from "typia"; - -interface ArrayNumberBase extends Array {} - -interface ArrayBoolean extends Array {} -interface ArrayNumber extends ArrayNumberBase {} -interface ArrayString extends Array {} - -console.log( - typia.createIs().toString(), - typia.createIs().toString(), -); -console.log( - typia.createIs().toString(), - typia.createIs().toString(), -); -console.log( - typia.createIs().toString(), - typia.createIs().toString(), -); -console.log(typia.createIs().toString()); -console.log(typia.createIs>().toString()); diff --git a/debug/features/camel.ts b/debug/features/camel.ts deleted file mode 100644 index 2f2005347d..0000000000 --- a/debug/features/camel.ts +++ /dev/null @@ -1,43 +0,0 @@ -import typia from "typia"; - -interface Something { - something: string; - SOMETHING: string; - - somethingMusic: string; - SomethingMusic: string; - something_music: string; - SOMETHING_MUSIC: string; - - x__y__z__and__something: string; -} -interface SomethingOfCamel { - something: string; - somethingMusic: string; - xYZAndSomething: string; -} -interface SomethingOfPascal { - Something: string; - SOMETHING: string; - SomethingMusic: string; - XYZAndSomething: string; -} -interface SomethingOfSnake { - something: string; - something_music: string; - x__y__z__and__something: string; -} - -const something: Something = typia.random(); -const x = typia.notations.camel(something); -const y = typia.notations.pascal(something); -const z = typia.notations.snake(something); - -console.log(x); -typia.assertEquals(x); - -console.log(y); -typia.assertEquals(y); - -console.log(z); -typia.assertEquals(z); diff --git a/debug/features/clone.ts b/debug/features/clone.ts deleted file mode 100644 index 4286752b0f..0000000000 --- a/debug/features/clone.ts +++ /dev/null @@ -1,38 +0,0 @@ -import typia, { tags } from "typia"; - -import { $clone } from "typia/lib/functional/$clone"; - -interface IBbsGroup { - id: string & tags.Format<"uuid">; - code: string; - name: string; - articles: IBbsArticle[]; -} -interface IBbsArticle { - id: string & tags.Format<"uuid">; - title: string; - content: string; - files: IAttachmentFile[]; - created_at: Date; - updated_at: Date; - deleted_at: Date | null; -} -interface IAttachmentFile { - id: string & tags.Format<"uri">; - name: string; - extension: string | null; - data: Uint8Array | DataView | Blob | File; -} - -new Array(1_000).fill(null).forEach(() => { - const group: IBbsGroup = { - ...typia.random(), - articles: new Array(10).fill(null).map(() => ({ - ...typia.random(), - files: new Array(10) - .fill(null) - .map(() => typia.random()), - })), - }; - typia.assert($clone(group)); -}); diff --git a/debug/features/description.ts b/debug/features/description.ts deleted file mode 100644 index 53004069c5..0000000000 --- a/debug/features/description.ts +++ /dev/null @@ -1,34 +0,0 @@ -import typia from "typia"; - -/** - * @title Something DTO - * @description This is a description of the Something DTO. - * - * Let's fill the content of it. - * @author Samchon - */ -interface Something { - /** - * This is the title. - * - * This is the description. - */ - id: string; - - /** - * This is not the description. - * - * @title Name - * @description This is the description of the name - */ - name: string; - - /** - * @description No title. - * - * Only description. - */ - description: string; -} - -console.log(JSON.stringify(typia.json.application<[Something]>(), null, 2)); diff --git a/debug/features/discriminator.ts b/debug/features/discriminator.ts deleted file mode 100644 index 61f4634fee..0000000000 --- a/debug/features/discriminator.ts +++ /dev/null @@ -1,43 +0,0 @@ -import typia from "typia"; - -interface Point { - type: "point"; - x: number; - y: number; -} -interface Line { - type: "line"; - p1: Point; - p2: Point; -} -interface Triangle { - type: "triangle"; - p1: Point; - p2: Point; - p3: Point; -} -interface Rectangle { - type: "rectangle"; - p1: Point; - p2: Point; - p3: Point; - p4: Point; -} -interface Polyline { - type: "polyline"; - points: Point[]; -} -interface Circle { - radius: number; -} - -console.log( - typia.json.application<[Point | Line | Triangle | Rectangle | Polyline]>() - .schemas[0], - typia.json.application< - [Point | Line | Triangle | Rectangle | Polyline | null] - >().schemas[0], - typia.json.application< - [Point | Line | Triangle | Rectangle | Polyline | Circle] - >().schemas[0], -); diff --git a/debug/features/dynamic.ts b/debug/features/dynamic.ts deleted file mode 100644 index c0dfe6f959..0000000000 --- a/debug/features/dynamic.ts +++ /dev/null @@ -1,11 +0,0 @@ -import typia from "typia"; - -console.log( - JSON.stringify( - typia.json.application< - [Record] - >(), - null, - 2, - ), -); diff --git a/debug/features/functional.ts b/debug/features/functional.ts deleted file mode 100644 index eef97aae99..0000000000 --- a/debug/features/functional.ts +++ /dev/null @@ -1,13 +0,0 @@ -import fs from "fs"; -import typia from "typia"; - -type Something = Promise; -const plus = async (x: number, y: number): Something => x + y; - -try { - fs.mkdirSync(__dirname + "/../bin"); -} catch {} -const func = typia.functional.isReturn(plus); -fs.writeFileSync(`${__dirname}/../bin/functional.js`, func.toString(), "utf8"); - -console.log(func(3, 4)); diff --git a/debug/features/intersection.ts b/debug/features/intersection.ts deleted file mode 100644 index 067c27f4fd..0000000000 --- a/debug/features/intersection.ts +++ /dev/null @@ -1,6 +0,0 @@ -import typia from "typia"; - -type Art = `${string}art${string}`; -type Bar = `${string}bar${string}`; - -console.log(typia.createIs().toString()); diff --git a/debug/features/join.ts b/debug/features/join.ts new file mode 100644 index 0000000000..62adb9ab9b --- /dev/null +++ b/debug/features/join.ts @@ -0,0 +1,9 @@ +import typia from "typia"; + +interface Foo { + paths?: { + [from: string]: [string]; + }; +} + +console.log(typia.createAssert().toString()); diff --git a/debug/features/name.ts b/debug/features/name.ts deleted file mode 100644 index d318f1fa0d..0000000000 --- a/debug/features/name.ts +++ /dev/null @@ -1,19 +0,0 @@ -import typia, { tags } from "typia"; - -type Something = string & tags.Format<"uuid">; -const value: number = 3; - -console.log( - typia.reflect.name>(), - typia.reflect.name>(), - typia.reflect.name(), - typia.reflect.name(), - typia.reflect.name(), - typia.reflect.name(), - typia.reflect.name< - string & - tags.JsonSchemaPlugin<{ - "x-typia-something": true; - }> - >(), -); diff --git a/debug/features/openapi.ts b/debug/features/openapi.ts deleted file mode 100644 index 838080c083..0000000000 --- a/debug/features/openapi.ts +++ /dev/null @@ -1,26 +0,0 @@ -import typia, { tags } from "typia"; - -type X = 3 & - tags.JsonSchemaPlugin<{ - title: "something"; - description: "nothing"; - }>; - -console.log( - JSON.stringify( - typia.json.application< - [ - X, - boolean & - tags.JsonSchemaPlugin<{ - title: "boolean"; - description: "hope not to be union of boolean literal types"; - }>, - ] - >(), - null, - 2, - ), - typia.createIs().toString(), - typia.reflect.metadata<[boolean]>().metadatas[0], -); diff --git a/debug/features/prisma.ts b/debug/features/prisma.ts deleted file mode 100644 index 2fb82f2bed..0000000000 --- a/debug/features/prisma.ts +++ /dev/null @@ -1,7 +0,0 @@ -import typia from "typia"; - -interface JsonArray extends Array { - children?: JsonArray; -} -const app = typia.json.application<[JsonArray]>(); -console.log(JSON.stringify(app, null, 2)); diff --git a/debug/features/protobuf.ts b/debug/features/protobuf.ts deleted file mode 100644 index b08928bafa..0000000000 --- a/debug/features/protobuf.ts +++ /dev/null @@ -1,6 +0,0 @@ -import typia from "typia"; - -interface ISomething { - data: Array<1 | 2 | 3>; -} -console.log(typia.protobuf.message()); diff --git a/debug/features/random.ts b/debug/features/random.ts deleted file mode 100644 index 608d6c1ebe..0000000000 --- a/debug/features/random.ts +++ /dev/null @@ -1,8 +0,0 @@ -import typia, { tags } from "typia"; - -interface IMember { - unique: string[] & tags.UniqueItems; - plain: number[]; -} - -console.log(typia.createRandom().toString()); diff --git a/debug/features/record.ts b/debug/features/record.ts deleted file mode 100644 index 3e20d59c2c..0000000000 --- a/debug/features/record.ts +++ /dev/null @@ -1,5 +0,0 @@ -import typia from "typia"; - -const app = typia.json.application<[Record], "3.1">(); - -console.log(JSON.stringify(app, null, 2)); diff --git a/debug/features/recursive.ts b/debug/features/recursive.ts deleted file mode 100644 index 95bb78022d..0000000000 --- a/debug/features/recursive.ts +++ /dev/null @@ -1,6 +0,0 @@ -import typia, { tags } from "typia"; - -interface Tree { - children?: Tree[] & tags.MinItems<1>; -} -console.log(typia.createIs().toString()); diff --git a/debug/features/resolved.ts b/debug/features/resolved.ts deleted file mode 100644 index 4db06d417f..0000000000 --- a/debug/features/resolved.ts +++ /dev/null @@ -1,9 +0,0 @@ -import typia, { Resolved } from "typia"; - -class Foo1 { - private _y: string; - constructor(public readonly x: string) { - this._y = "y"; - } -} -console.log(typia.createEquals>().toString()); diff --git a/debug/features/schema.ts b/debug/features/schema.ts deleted file mode 100644 index 125ad9a994..0000000000 --- a/debug/features/schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -import typia, { tags } from "typia"; - -const app = - typia.json.application< - [ - string & tags.Format<"uuid">, - number & tags.Minimum<3>, - number & tags.Type<"int32">, - ] - >(); -console.log(app.schemas); diff --git a/debug/features/set.ts b/debug/features/set.ts deleted file mode 100644 index ff942c3c88..0000000000 --- a/debug/features/set.ts +++ /dev/null @@ -1,21 +0,0 @@ -import typia from "typia"; - -type Values = - | false - | 1 - | 2 - | 3 - | 4 - | 5 - | "six" - | "seven" - | 8n - | 9n - | "ten" - | "eleven"; - -console.log( - typia.createIs().toString(), - typia.createAssert().toString(), - typia.createValidate().toString(), -); diff --git a/debug/features/template.ts b/debug/features/template.ts deleted file mode 100644 index be8280b1dd..0000000000 --- a/debug/features/template.ts +++ /dev/null @@ -1,37 +0,0 @@ -import fs from "fs"; -import typia, { tags } from "typia"; - -interface Something { - pure: `${number}/${number}` | `${string}-${string}`; - sole: `${number}/${number}` & tags.JsonSchemaPlugin<{ "x-typia-sole": true }>; - union: - | (`${number}/${number}` & - tags.JsonSchemaPlugin<{ "x-typia-something": true }>) - | (`${string}-${string}` & - tags.JsonSchemaPlugin<{ "x-typia-nothing": false }>); - mixed: - | `${number}/${number}` - | `${string}-${string}` - | (`${string}||${number}` & - tags.JsonSchemaPlugin<{ "x-typia-something": true }>); - boolean_and_number_and_template: boolean | number | `prefix_${string}`; -} - -try { - fs.mkdirSync("assets"); -} catch {} -fs.writeFileSync( - "assets/template.is.ts", - typia.createIs().toString(), - "utf8", -); -fs.writeFileSync( - "assets/template.metadata.json", - JSON.stringify(typia.reflect.metadata<[Something]>(), null, 2), - "utf8", -); -fs.writeFileSync( - "assets/template.schema.json", - JSON.stringify(typia.json.application<[Something]>(), null, 2), - "utf8", -); diff --git a/debug/features/type.ts b/debug/features/type.ts deleted file mode 100644 index 295c8b277e..0000000000 --- a/debug/features/type.ts +++ /dev/null @@ -1,12 +0,0 @@ -import typia, { tags } from "typia"; - -interface Something { - /** - * @type int64 - */ - value: number & tags.Minimum<3>; -} - -console.log( - typia.json.application<[Something]>().components.schemas?.Something, -); diff --git a/debug/features/unique.ts b/debug/features/unique.ts deleted file mode 100644 index e3d73295b8..0000000000 --- a/debug/features/unique.ts +++ /dev/null @@ -1,12 +0,0 @@ -import typia, { tags } from "typia"; - -console.log( - JSON.stringify( - typia.json.application<[number[] & tags.UniqueItems]>(), - null, - 2, - ), - typia.is([1, 2, 3]), - typia.is([1, 2, 2]), - typia.is>(["one", "two", "one"]), -); diff --git a/debug/package.json b/debug/package.json index c6ef3553d7..b72521d721 100644 --- a/debug/package.json +++ b/debug/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "node index", - "prepare": "ts-patch install && typia patch" + "prepare": "ts-patch install && typia patch", + "build": "node build" }, "author": "", "license": "ISC", @@ -15,6 +16,6 @@ "typescript": "^5.4.2" }, "dependencies": { - "typia": "../typia-6.5.4-dev.20240721.tgz" + "typia": "../typia-6.5.5.tgz" } } \ No newline at end of file diff --git a/errors/package.json b/errors/package.json index 282a1efe9b..475a83de28 100644 --- a/errors/package.json +++ b/errors/package.json @@ -32,6 +32,6 @@ "typescript": "^5.3.2" }, "dependencies": { - "typia": "../typia-6.5.4.tgz" + "typia": "../typia-6.5.5.tgz" } } \ No newline at end of file diff --git a/package.json b/package.json index cca9a31b35..76ad6d7a55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typia", - "version": "6.5.4", + "version": "6.5.5", "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 9ff123bbfc..0f2e1f0bf6 100644 --- a/packages/typescript-json/package.json +++ b/packages/typescript-json/package.json @@ -1,6 +1,6 @@ { "name": "typescript-json", - "version": "6.5.4", + "version": "6.5.5", "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.4" + "typia": "6.5.5" }, "peerDependencies": { "typescript": ">=4.8.0 <5.6.0" diff --git a/src/programmers/CheckerProgrammer.ts b/src/programmers/CheckerProgrammer.ts index 81c8ac38aa..6e8da21b0b 100644 --- a/src/programmers/CheckerProgrammer.ts +++ b/src/programmers/CheckerProgrammer.ts @@ -33,6 +33,7 @@ import { check_number } from "./internal/check_number"; import { check_string } from "./internal/check_string"; import { check_template } from "./internal/check_template"; import { decode_union_object } from "./internal/decode_union_object"; +import { postfix_of_tuple } from "./internal/postfix_of_tuple"; import { wrap_metadata_rest_tuple } from "./internal/wrap_metadata_rest_tuple"; export namespace CheckerProgrammer { @@ -766,7 +767,7 @@ export namespace CheckerProgrammer { ...explore, from: "array", postfix: explore.postfix.length - ? `${explore.postfix.slice(0, -1)}[${index}]"` + ? `${postfix_of_tuple(explore.postfix)}[${index}]"` : `"[${index}]"`, }, ), diff --git a/src/programmers/internal/postfix_of_tuple.ts b/src/programmers/internal/postfix_of_tuple.ts new file mode 100644 index 0000000000..7b89232d59 --- /dev/null +++ b/src/programmers/internal/postfix_of_tuple.ts @@ -0,0 +1,2 @@ +export const postfix_of_tuple = (str: string): string => + str.endsWith('"') ? str.slice(0, -1) : `${str} + "`; diff --git a/src/programmers/json/JsonStringifyProgrammer.ts b/src/programmers/json/JsonStringifyProgrammer.ts index 9f19ab5543..d6ca47faa0 100644 --- a/src/programmers/json/JsonStringifyProgrammer.ts +++ b/src/programmers/json/JsonStringifyProgrammer.ts @@ -33,6 +33,7 @@ import { UnionExplorer } from "../helpers/UnionExplorer"; import { check_native } from "../internal/check_native"; import { decode_union_object } from "../internal/decode_union_object"; import { feature_object_entries } from "../internal/feature_object_entries"; +import { postfix_of_tuple } from "../internal/postfix_of_tuple"; import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple"; export namespace JsonStringifyProgrammer { @@ -543,7 +544,7 @@ export namespace JsonStringifyProgrammer { ...explore, from: "array", postfix: explore.postfix.length - ? `${explore.postfix.slice(0, -1)}[${index}]"` + ? `${postfix_of_tuple(explore.postfix)}[${index}]"` : `"[${index}]"`, }, ), diff --git a/src/programmers/misc/MiscCloneProgrammer.ts b/src/programmers/misc/MiscCloneProgrammer.ts index 8d4b86ef74..ab65135f02 100644 --- a/src/programmers/misc/MiscCloneProgrammer.ts +++ b/src/programmers/misc/MiscCloneProgrammer.ts @@ -21,6 +21,7 @@ import { CloneJoiner } from "../helpers/CloneJoiner"; import { FunctionImporter } from "../helpers/FunctionImporter"; import { UnionExplorer } from "../helpers/UnionExplorer"; import { decode_union_object } from "../internal/decode_union_object"; +import { postfix_of_tuple } from "../internal/postfix_of_tuple"; import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple"; export namespace MiscCloneProgrammer { @@ -335,7 +336,7 @@ export namespace MiscCloneProgrammer { ...explore, from: "array", postfix: explore.postfix.length - ? `${explore.postfix.slice(0, -1)}[${index}]"` + ? `${postfix_of_tuple(explore.postfix)}[${index}]"` : `"[${index}]"`, }, ), diff --git a/src/programmers/misc/MiscPruneProgrammer.ts b/src/programmers/misc/MiscPruneProgrammer.ts index 0c4bd3baa7..225d579736 100644 --- a/src/programmers/misc/MiscPruneProgrammer.ts +++ b/src/programmers/misc/MiscPruneProgrammer.ts @@ -21,6 +21,7 @@ import { FunctionImporter } from "../helpers/FunctionImporter"; import { PruneJoiner } from "../helpers/PruneJoiner"; import { UnionExplorer } from "../helpers/UnionExplorer"; import { decode_union_object } from "../internal/decode_union_object"; +import { postfix_of_tuple } from "../internal/postfix_of_tuple"; import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple"; export namespace MiscPruneProgrammer { @@ -302,7 +303,7 @@ export namespace MiscPruneProgrammer { ...explore, from: "array", postfix: explore.postfix.length - ? `${explore.postfix.slice(0, -1)}[${index}]"` + ? `${postfix_of_tuple(explore.postfix)}[${index}]"` : `"[${index}]"`, }, ), diff --git a/src/programmers/notations/NotationGeneralProgrammer.ts b/src/programmers/notations/NotationGeneralProgrammer.ts index 87ef682a45..2c3170b617 100644 --- a/src/programmers/notations/NotationGeneralProgrammer.ts +++ b/src/programmers/notations/NotationGeneralProgrammer.ts @@ -23,6 +23,7 @@ import { FunctionImporter } from "../helpers/FunctionImporter"; import { NotationJoiner } from "../helpers/NotationJoiner"; import { UnionExplorer } from "../helpers/UnionExplorer"; import { decode_union_object } from "../internal/decode_union_object"; +import { postfix_of_tuple } from "../internal/postfix_of_tuple"; import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple"; export namespace NotationGeneralProgrammer { @@ -345,7 +346,7 @@ export namespace NotationGeneralProgrammer { ...explore, from: "array", postfix: explore.postfix.length - ? `${explore.postfix.slice(0, -1)}[${index}]"` + ? `${postfix_of_tuple(explore.postfix)}[${index}]"` : `"[${index}]"`, }, ), diff --git a/test-esm/package.json b/test-esm/package.json index e68a8a9a81..8118dff9f8 100644 --- a/test-esm/package.json +++ b/test-esm/package.json @@ -36,6 +36,6 @@ "typescript": "^5.4.5" }, "dependencies": { - "typia": "../typia-6.5.4.tgz" + "typia": "../typia-6.5.5.tgz" } } \ No newline at end of file diff --git a/test/package.json b/test/package.json index 9688175e4f..9ab666e470 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.4.tgz" + "typia": "../typia-6.5.5.tgz" } } \ No newline at end of file diff --git a/test/src/features/issues/test_issue_1179_tuple_type_in_dynamic_object.ts b/test/src/features/issues/test_issue_1179_tuple_type_in_dynamic_object.ts new file mode 100644 index 0000000000..19009cf94c --- /dev/null +++ b/test/src/features/issues/test_issue_1179_tuple_type_in_dynamic_object.ts @@ -0,0 +1,14 @@ +import typia from "typia"; + +export const test_issue_1179_tuple_type_in_dynamic_object = (): void => { + new Array(100).forEach(() => { + const foo: Foo = typia.random(); + typia.assert(foo); + }); +}; + +interface Foo { + paths?: { + [from: string]: [string]; + }; +} diff --git a/website/package.json b/website/package.json index d696ed83e3..e2042e4d44 100644 --- a/website/package.json +++ b/website/package.json @@ -36,8 +36,8 @@ "react-dom": "^18.2.0", "tgrid": "^1.0.2", "tstl": "^3.0.0", - "typescript": "^5.5.3", - "typia": "^6.5.4" + "typescript": "^5.5.4", + "typia": "^6.5.5" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0",