Skip to content

Commit

Permalink
Merge pull request #805 from samchon/features/noUncheckedIndexedAccess
Browse files Browse the repository at this point in the history
Fix #804 - support `noUncheckedIndexedAccess` option.
  • Loading branch information
samchon committed Sep 5, 2023
2 parents b0005b7 + 4b91066 commit e387322
Show file tree
Hide file tree
Showing 240 changed files with 2,271 additions and 2,143 deletions.
6 changes: 3 additions & 3 deletions benchmark/internal/HorizontalBarChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export namespace HorizontalBarChart {
.attr("y", style.margin.top + 20 * i)
.attr("width", 10)
.attr("height", 10)
.style("fill", style.colors[i]);
.style("fill", style.colors[i]!);
svg.append("text")
.attr("x", style.width - style.margin.right + 10 + 25)
.attr("y", style.margin.top + 20 * i + 10)
Expand Down Expand Up @@ -175,11 +175,11 @@ export namespace HorizontalBarChart {
column,
category: d.label,
value:
d.result[column] !== 0 &&
d.result[column]! !== 0 &&
Object.values(d.result).filter((val) => val !== 0)
.length === 1
? Number.POSITIVE_INFINITY
: d.result[column],
: d.result[column]!,
})),
);

Expand Down
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": "5.0.1",
"version": "5.0.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "5.0.1",
"version": "5.0.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -72,7 +72,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "5.0.1"
"typia": "5.0.2"
},
"peerDependencies": {
"typescript": ">= 4.7.4"
Expand Down
110 changes: 59 additions & 51 deletions src/programmers/internal/check_union_array_like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,60 +49,63 @@ export const check_union_array_like =
(t) => t instanceof MetadataArray,
) as MetadataArray[];

const predicate = (meta: Category): ts.ArrayLiteralExpression =>
ts.factory.createArrayLiteralExpression(
[
ts.factory.createArrowFunction(
undefined,
undefined,
[
IdentifierFactory.parameter(
"top",
meta instanceof MetadataArrayType
? TypeFactory.keyword("any")
: ts.factory.createTypeReferenceNode(
"any[]",
),
),
],
TypeFactory.keyword("any"),
undefined,
props.checker(
ts.factory.createIdentifier("top"),
accessor.element(meta),
{
...explore,
tracable: false,
postfix:
const predicate = (meta: Category): ts.Expression =>
ts.factory.createAsExpression(
ts.factory.createArrayLiteralExpression(
[
ts.factory.createArrowFunction(
undefined,
undefined,
[
IdentifierFactory.parameter(
"top",
meta instanceof MetadataArrayType
? `"[0]"`
: "",
},
array,
? TypeFactory.keyword("any")
: ts.factory.createTypeReferenceNode(
"any[]",
),
),
],
TypeFactory.keyword("any"),
undefined,
props.checker(
ts.factory.createIdentifier("top"),
accessor.element(meta),
{
...explore,
tracable: false,
postfix:
meta instanceof MetadataArrayType
? `"[0]"`
: "",
},
array,
),
),
),
ts.factory.createArrowFunction(
undefined,
undefined,
[
IdentifierFactory.parameter(
"entire",
ts.factory.createTypeReferenceNode("any[]"),
ts.factory.createArrowFunction(
undefined,
undefined,
[
IdentifierFactory.parameter(
"entire",
ts.factory.createTypeReferenceNode("any[]"),
),
],
TypeFactory.keyword("any"),
undefined,
props.decoder(
ts.factory.createIdentifier("entire"),
meta,
{
...explore,
tracable: true,
},
),
],
TypeFactory.keyword("any"),
undefined,
props.decoder(
ts.factory.createIdentifier("entire"),
meta,
{
...explore,
tracable: true,
},
),
),
],
true,
],
true,
),
ts.factory.createTypeReferenceNode("const"),
);
const iterate =
(init: string) =>
Expand Down Expand Up @@ -200,7 +203,12 @@ export const check_union_array_like =
),
ts.factory.createReturnStatement(
ts.factory.createCallExpression(
ts.factory.createIdentifier(`passed[0][1]`),
ts.factory.createElementAccessExpression(
ts.factory.createNonNullExpression(
ts.factory.createIdentifier("passed[0]"),
),
1,
),
undefined,
[array],
),
Expand Down
16 changes: 8 additions & 8 deletions test/generated/output/assert/test_assert_ArrayRepeatedUnion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const test_assert_ArrayRepeatedUnion = _test_assert(
entire.every(
(elem: any) => "string" === typeof elem,
),
],
] as const,
[
(top: any[]): any =>
null !== top &&
Expand All @@ -28,7 +28,7 @@ export const test_assert_ArrayRepeatedUnion = _test_assert(
"boolean" === typeof top ||
(Array.isArray(top) && ($ip0(top) || false))),
(entire: any[]): any => $ia0(entire) || false,
],
] as const,
[
(top: any[]): any =>
"object" === typeof top &&
Expand All @@ -41,12 +41,12 @@ export const test_assert_ArrayRepeatedUnion = _test_assert(
null !== elem &&
$io0(elem),
),
],
] as const,
];
const passed = arrayPredicators.filter((pred: any) =>
pred[0](top),
);
if (1 === passed.length) return passed[0][1](array);
if (1 === passed.length) return passed[0]![1](array);
else if (1 < passed.length)
for (const pred of passed)
if (
Expand Down Expand Up @@ -133,7 +133,7 @@ export const test_assert_ArrayRepeatedUnion = _test_assert(
value: elem,
}),
),
],
] as const,
[
(top: any[]): any =>
null !== top &&
Expand All @@ -160,7 +160,7 @@ export const test_assert_ArrayRepeatedUnion = _test_assert(
expected: "Array<ArrayRepeatedUnion>",
value: entire,
}),
],
] as const,
[
(top: any[]): any =>
"object" === typeof top &&
Expand Down Expand Up @@ -190,12 +190,12 @@ export const test_assert_ArrayRepeatedUnion = _test_assert(
value: elem,
}),
),
],
] as const,
];
const passed = arrayPredicators.filter((pred: any) =>
pred[0](top),
);
if (1 === passed.length) return passed[0][1](array);
if (1 === passed.length) return passed[0]![1](array);
else if (1 < passed.length)
for (const pred of passed)
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
"number" === typeof entire[1] &&
Number.isFinite(entire[1]) &&
"boolean" === typeof entire[2],
],
] as const,
[
(top: any[]): any =>
top.length === 2 &&
Expand All @@ -41,7 +41,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
"object" === typeof entire[1] &&
null !== entire[1] &&
$io1(entire[1]),
],
] as const,
];
for (const pred of tuplePredicators)
if (pred[0](array)) return pred[1](array);
Expand All @@ -54,7 +54,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
entire.every(
(elem: any) => "string" === typeof elem,
),
],
] as const,
[
(top: any[]): any =>
null !== top &&
Expand All @@ -64,7 +64,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
"boolean" === typeof top ||
(Array.isArray(top) && ($ip0(top) || false))),
(entire: any[]): any => $ia0(entire) || false,
],
] as const,
[
(top: any[]): any =>
"object" === typeof top &&
Expand All @@ -77,12 +77,12 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
null !== elem &&
$io0(elem),
),
],
] as const,
];
const passed = arrayPredicators.filter((pred: any) =>
pred[0](top),
);
if (1 === passed.length) return passed[0][1](array);
if (1 === passed.length) return passed[0]![1](array);
else if (1 < passed.length)
for (const pred of passed)
if (
Expand Down Expand Up @@ -195,7 +195,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
expected: "boolean",
value: entire[2],
})),
],
] as const,
[
(top: any[]): any =>
top.length === 2 &&
Expand Down Expand Up @@ -259,7 +259,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
"ArrayRepeatedUnionWithTuple.IPoint3D",
value: entire[1],
})),
],
] as const,
];
for (const pred of tuplePredicators)
if (pred[0](array)) return pred[1](array);
Expand All @@ -278,7 +278,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
value: elem,
}),
),
],
] as const,
[
(top: any[]): any =>
null !== top &&
Expand Down Expand Up @@ -306,7 +306,7 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
"Array<ArrayRepeatedUnionWithTuple>",
value: entire,
}),
],
] as const,
[
(top: any[]): any =>
"object" === typeof top &&
Expand Down Expand Up @@ -336,12 +336,12 @@ export const test_assert_ArrayRepeatedUnionWithTuple = _test_assert(
value: elem,
}),
),
],
] as const,
];
const passed = arrayPredicators.filter((pred: any) =>
pred[0](top),
);
if (1 === passed.length) return passed[0][1](array);
if (1 === passed.length) return passed[0]![1](array);
else if (1 < passed.length)
for (const pred of passed)
if (
Expand Down
Loading

0 comments on commit e387322

Please sign in to comment.