Skip to content

Commit ab39b05

Browse files
authored
Merge pull request #874 from samchon/features/exactOptionalPropertyTypes
Close #848 - `exactOptionalPropertyTypes` option for `typia.protobuf.decode<T>()` function.
2 parents 6e314ed + 6cbae8b commit ab39b05

File tree

1,077 files changed

+2446
-3238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,077 files changed

+2446
-3238
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typia",
3-
"version": "5.3.0-dev.20231117",
3+
"version": "5.3.0-dev.20231120",
44
"description": "Superfast runtime validators with only one line",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/typescript-json/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-json",
3-
"version": "5.3.0-dev.20231117",
3+
"version": "5.3.0-dev.20231120",
44
"description": "Superfast runtime validators with only one line",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -72,7 +72,7 @@
7272
},
7373
"homepage": "https://typia.io",
7474
"dependencies": {
75-
"typia": "5.3.0-dev.20231117"
75+
"typia": "5.3.0-dev.20231120"
7676
},
7777
"peerDependencies": {
7878
"typescript": ">=4.8.0 <5.3.0"

src/programmers/protobuf/ProtobufDecodeProgrammer.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,25 @@ export namespace ProtobufDecodeProgrammer {
165165
return [
166166
StatementFactory.constant(
167167
props.output,
168-
ts.factory.createObjectLiteralExpression(
169-
properties.map((p) =>
170-
ts.factory.createPropertyAssignment(
171-
IdentifierFactory.identifier(p.key.getSoleLiteral()!),
172-
write_property_default_value(p.value),
173-
),
168+
ts.factory.createAsExpression(
169+
ts.factory.createObjectLiteralExpression(
170+
properties
171+
.filter(
172+
(p) =>
173+
!(
174+
project.compilerOptions.exactOptionalPropertyTypes ===
175+
true && p.value.optional === true
176+
),
177+
)
178+
.map((p) =>
179+
ts.factory.createPropertyAssignment(
180+
IdentifierFactory.identifier(p.key.getSoleLiteral()!),
181+
write_property_default_value(p.value),
182+
),
183+
),
184+
true,
174185
),
175-
true,
186+
TypeFactory.keyword("any"),
176187
),
177188
),
178189
ts.factory.createWhileStatement(

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ArrayHierarchicalPointer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const test_protobuf_createAssertDecode_ArrayHierarchicalPointer =
1616
length = length < 0 ? reader.size() : reader.index() + length;
1717
const output = {
1818
value: [] as any,
19-
};
19+
} as any;
2020
while (reader.index() < length) {
2121
const tag = reader.uint32();
2222
switch (tag >>> 3) {
@@ -39,7 +39,7 @@ export const test_protobuf_createAssertDecode_ArrayHierarchicalPointer =
3939
name: "" as any,
4040
established_at: undefined as any,
4141
departments: [] as any,
42-
};
42+
} as any;
4343
while (reader.index() < length) {
4444
const tag = reader.uint32();
4545
switch (tag >>> 3) {
@@ -75,7 +75,7 @@ export const test_protobuf_createAssertDecode_ArrayHierarchicalPointer =
7575
const output = {
7676
time: undefined as any,
7777
zone: undefined as any,
78-
};
78+
} as any;
7979
while (reader.index() < length) {
8080
const tag = reader.uint32();
8181
switch (tag >>> 3) {
@@ -102,7 +102,7 @@ export const test_protobuf_createAssertDecode_ArrayHierarchicalPointer =
102102
sales: undefined as any,
103103
created_at: undefined as any,
104104
employees: [] as any,
105-
};
105+
} as any;
106106
while (reader.index() < length) {
107107
const tag = reader.uint32();
108108
switch (tag >>> 3) {
@@ -141,7 +141,7 @@ export const test_protobuf_createAssertDecode_ArrayHierarchicalPointer =
141141
age: undefined as any,
142142
grade: undefined as any,
143143
employeed_at: undefined as any,
144-
};
144+
} as any;
145145
while (reader.index() < length) {
146146
const tag = reader.uint32();
147147
switch (tag >>> 3) {

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ArrayRecursive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursive =
1919
code: "" as any,
2020
sequence: undefined as any,
2121
created_at: undefined as any,
22-
};
22+
} as any;
2323
while (reader.index() < length) {
2424
const tag = reader.uint32();
2525
switch (tag >>> 3) {
@@ -55,7 +55,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursive =
5555
const output = {
5656
time: undefined as any,
5757
zone: undefined as any,
58-
};
58+
} as any;
5959
while (reader.index() < length) {
6060
const tag = reader.uint32();
6161
switch (tag >>> 3) {

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ArrayRecursiveUnionExplicitPointer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
1818
length = length < 0 ? reader.size() : reader.index() + length;
1919
const output = {
2020
value: [] as any,
21-
};
21+
} as any;
2222
while (reader.index() < length) {
2323
const tag = reader.uint32();
2424
switch (tag >>> 3) {
@@ -37,7 +37,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
3737
length = length < 0 ? reader.size() : reader.index() + length;
3838
const output = {
3939
value: undefined as any,
40-
};
40+
} as any;
4141
while (reader.index() < length) {
4242
const tag = reader.uint32();
4343
switch (tag >>> 3) {
@@ -76,7 +76,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
7676
path: "" as any,
7777
children: [] as any,
7878
type: undefined as any,
79-
};
79+
} as any;
8080
while (reader.index() < length) {
8181
const tag = reader.uint32();
8282
switch (tag >>> 3) {
@@ -119,7 +119,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
119119
size: undefined as any,
120120
type: undefined as any,
121121
extension: undefined as any,
122-
};
122+
} as any;
123123
while (reader.index() < length) {
124124
const tag = reader.uint32();
125125
switch (tag >>> 3) {
@@ -176,7 +176,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
176176
content: "" as any,
177177
type: undefined as any,
178178
extension: undefined as any,
179-
};
179+
} as any;
180180
while (reader.index() < length) {
181181
const tag = reader.uint32();
182182
switch (tag >>> 3) {
@@ -225,7 +225,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
225225
count: undefined as any,
226226
type: undefined as any,
227227
extension: undefined as any,
228-
};
228+
} as any;
229229
while (reader.index() < length) {
230230
const tag = reader.uint32();
231231
switch (tag >>> 3) {
@@ -273,7 +273,7 @@ export const test_protobuf_createAssertDecode_ArrayRecursiveUnionExplicitPointer
273273
target: undefined as any,
274274
type: undefined as any,
275275
extension: undefined as any,
276-
};
276+
} as any;
277277
while (reader.index() < length) {
278278
const tag = reader.uint32();
279279
switch (tag >>> 3) {

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ArraySimpleProtobuf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const test_protobuf_createAssertDecode_ArraySimpleProtobuf =
2525
string: [] as any,
2626
bytes: [] as any,
2727
object: [] as any,
28-
};
28+
} as any;
2929
while (reader.index() < length) {
3030
const tag = reader.uint32();
3131
switch (tag >>> 3) {

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ArraySimpleProtobufNullable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const test_protobuf_createAssertDecode_ArraySimpleProtobufNullable =
2525
string: null as any,
2626
bytes: null as any,
2727
object: null as any,
28-
};
28+
} as any;
2929
while (reader.index() < length) {
3030
const tag = reader.uint32();
3131
switch (tag >>> 3) {

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ArraySimpleProtobufOptional.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,7 @@ export const test_protobuf_createAssertDecode_ArraySimpleProtobufOptional =
1414
const $Reader = (typia.protobuf.assertDecode as any).Reader;
1515
const $pdo0 = (reader: any, length: number = -1): any => {
1616
length = length < 0 ? reader.size() : reader.index() + length;
17-
const output = {
18-
boolean: undefined as any,
19-
int32: undefined as any,
20-
uint32: undefined as any,
21-
int64: undefined as any,
22-
uint64: undefined as any,
23-
float: undefined as any,
24-
double: undefined as any,
25-
string: undefined as any,
26-
bytes: undefined as any,
27-
object: undefined as any,
28-
};
17+
const output = {} as any;
2918
while (reader.index() < length) {
3019
const tag = reader.uint32();
3120
switch (tag >>> 3) {

test/generated/output/protobuf.assertDecode/test_protobuf_assertDecode_ClassMethod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const test_protobuf_createAssertDecode_ClassMethod =
1313
const output = {
1414
name: "" as any,
1515
age: undefined as any,
16-
};
16+
} as any;
1717
while (reader.index() < length) {
1818
const tag = reader.uint32();
1919
switch (tag >>> 3) {

0 commit comments

Comments
 (0)