Skip to content

Commit

Permalink
Merge pull request #242 from samchon/v3.3
Browse files Browse the repository at this point in the history
Close #241 - ignore `@internal` tagged properties
  • Loading branch information
samchon authored Oct 16, 2022
2 parents 8b4895e + 2b60a4e commit bc22959
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "3.3.10",
"version": "3.3.11",
"description": "Runtime type checkers and 5x faster JSON.stringify() function",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/factories/internal/emplace_metadata_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export const emplace_metadata_object =
// REGULAR PROPERTIES
//----
for (const prop of parent.getApparentProperties()) {
// CHECK INTERNAL TAG
if (
(prop.getJsDocTags(checker) || []).find(
(tag) => tag.name === "internal",
) !== undefined
)
continue;

// CHECK NODE IS A FORMAL PROPERTY
const [node, type] = (() => {
const node = (prop.getDeclarations() || [])[0] as
Expand Down
37 changes: 37 additions & 0 deletions test/features/application/test_application_object_internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_application } from "./_test_application";

export const test_application_object_internal = _test_application(
"internal object",
TSON.application<[ObjectInternal]>(),
{
schemas: [
{
$ref: "#/components/schemas/ObjectInternal",
},
],
components: {
schemas: {
ObjectInternal: {
type: "object",
properties: {
id: {
type: "string",
nullable: false,
},
name: {
type: "string",
nullable: false,
},
},
nullable: false,
required: ["id", "name"],
jsDocTags: [],
},
},
},
purpose: "swagger",
prefix: "#/components/schemas",
},
);
19 changes: 19 additions & 0 deletions test/features/assert/test_assert_object_internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_assert } from "./_test_assert";

export const test_assert_object_internal = _test_assert(
"object internal",
ObjectInternal.generate,
(input) => TSON.assertType(input),
[
(input) => {
input.name = false as any;
return "$input.name";
},
(input) => {
input.id = 1 as any;
return "$input.id";
},
],
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_assert_equals } from "./_test_assert_equals";

export const test_assert_equals_object_internal = _test_assert_equals(
"object internal",
ObjectInternal.generate,
(input) => TSON.assertEquals(input),
);
9 changes: 9 additions & 0 deletions test/features/equals/test_equals_object_internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_equals } from "./_test_equals";

export const test_equals_object_internal = _test_equals(
"object internal",
ObjectInternal.generate,
(input) => TSON.equals(input),
);
10 changes: 10 additions & 0 deletions test/features/is/test_is_object_internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_is } from "./_test_is";

export const test_is_object_internal = _test_is(
"object internal",
ObjectInternal.generate,
(input) => TSON.is(input),
[(elem) => (elem.id = false as any), (elem) => (elem.name = 1 as any)],
);
9 changes: 9 additions & 0 deletions test/features/stringify/test_stringify_object_internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_stringify } from "./_test_stringify";

export const test_stringify_object_internal = _test_stringify(
"object internal",
ObjectInternal.generate(),
(input) => TSON.stringify(input),
);
19 changes: 19 additions & 0 deletions test/features/validate/test_validate_object_internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_validate } from "./_test_validate";

export const test_validate_object_internal = _test_validate(
"object internal",
ObjectInternal.generate,
(input) => TSON.validate(input),
[
(input) => {
input.name = false as any;
return ["$input.name"];
},
(input) => {
input.id = 1 as any;
return ["$input.id"];
},
],
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import TSON from "../../../src";
import { ObjectInternal } from "../../structures/ObjectInternal";
import { _test_validate_equals } from "./_test_validate_equals";

export const test_validate_equals_object_internal = _test_validate_equals(
"object internal",
ObjectInternal.generate,
(input) => TSON.validateEquals(input),
);
17 changes: 17 additions & 0 deletions test/structures/ObjectInternal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export interface ObjectInternal {
id: string;
name: string;

/**
* @internal
*/
__age: number;
}
export namespace ObjectInternal {
export function generate(): ObjectInternal {
return {
id: "id",
name: "name",
} as ObjectInternal;
}
}

0 comments on commit bc22959

Please sign in to comment.