typia 5.0.0-dev.20230830 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -77,7 +77,7 @@ Check out the document in the [website](https://typia.io/docs/):
77
77
  - [`is()` function](https://typia.io/docs/validators/is/)
78
78
  - [`assert()` function](https://typia.io/docs/validators/assert/)
79
79
  - [`validate()` function](https://typia.io/docs/validators/validate/)
80
- - [Custom Tags](https://typia.io/docs/validators/tags/)
80
+ - [Special Tags](https://typia.io/docs/validators/tags/)
81
81
  - Enhanced JSON
82
82
  - [`stringify()` functions](https://typia.io/docs/json/stringify/)
83
83
  - [`parse()` functions](https://typia.io/docs/json/parse/)
@@ -1,14 +1,56 @@
1
1
  export type TagBase<Props extends TagBase.IProps<any, any, any, any, any>> = {
2
+ /**
3
+ * This is a dummy property for compilation.
4
+ *
5
+ * It does not mean anything in runtime.
6
+ */
2
7
  "typia.tag"?: Props;
3
8
  };
4
9
  export declare namespace TagBase {
5
10
  interface IProps<Target extends "bigint" | "number" | "string" | "array", Kind extends string, Value extends boolean | bigint | number | string | undefined, Validate extends string | {
6
11
  [key in Target]?: string;
7
12
  }, Exclusive extends boolean | string[]> {
13
+ /**
14
+ * Target type.
15
+ *
16
+ * If user tries to adapt this tag to a different type, it would be a compile
17
+ * error.
18
+ *
19
+ * For example, you've configured target type as `string`, but user adapted it
20
+ * onto a `number` type (`number & YourCustomTag<Value>`), then it would be
21
+ * blocked by TypeScript compiler.
22
+ */
8
23
  target: Target;
24
+ /**
25
+ * What kind of tag is this?
26
+ */
9
27
  kind: Kind;
28
+ /**
29
+ * Value to be configured by user.
30
+ */
10
31
  value: Value;
32
+ /**
33
+ * Validation script.
34
+ *
35
+ * This script would be inserted into the generated validation function.
36
+ * In here script, target variable name must be `$input`. The variable name
37
+ * `$input` would be transformed to the suitable when compilation.
38
+ *
39
+ * Also, If you've take a mistake on this script, compile error would be
40
+ * occured. So, define it with confidence. Compiler will block all your
41
+ * mistakes.
42
+ */
11
43
  validate: Validate;
44
+ /**
45
+ * Exclusive option.
46
+ *
47
+ * If this property configured as `true`, same {@link kind} tag cannot be
48
+ * duplicated in the target type. Otherwise, if you've configured this
49
+ * property as string array, all of the {@link kind} value assigned
50
+ * tags cannot be compatible in the target type.
51
+ *
52
+ * @default false
53
+ */
12
54
  exclusive?: Exclusive | string[];
13
55
  }
14
56
  }
@@ -31,8 +31,8 @@ var FileTransformer;
31
31
  var iterate_node = function (project) {
32
32
  return function (context) {
33
33
  return function (node) {
34
- var changed = try_transform_node(project)(node);
35
- return typescript_1.default.visitEachChild(changed !== null && changed !== void 0 ? changed : node, function (child) { return iterate_node(project)(context)(child); }, context);
34
+ var _a;
35
+ return typescript_1.default.visitEachChild((_a = try_transform_node(project)(node)) !== null && _a !== void 0 ? _a : node, function (child) { return iterate_node(project)(context)(child); }, context);
36
36
  };
37
37
  };
38
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FileTransformer.js","sourceRoot":"","sources":["../../src/transformers/FileTransformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAG5B,qDAAoD;AAGpD,IAAiB,eAAe,CA6C/B;AA7CD,WAAiB,eAAe;IACf,yBAAS,GAClB,UAAC,OAAkC;QACnC,OAAA,UAAC,OAAiC;YAClC,OAAA,UAAC,IAAmB;gBAChB,IAAI,IAAI,CAAC,iBAAiB;oBAAE,OAAO,IAAI,CAAC;gBACxC,OAAO,oBAAE,CAAC,cAAc,CACpB,IAAI,EACJ,UAAC,IAAI,IAAK,OAAA,YAAY,uBAAM,OAAO,KAAE,OAAO,SAAA,IAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAApD,CAAoD,EAC9D,OAAO,CACV,CAAC;YACN,CAAC;QAPD,CAOC;IARD,CAQC,CAAC;IAEN,IAAM,YAAY,GACd,UAAC,OAAiB;QAClB,OAAA,UAAC,OAAiC;YAClC,OAAA,UAAC,IAAa;gBACV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AAE;oBAChD,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,QAAQ,EAAE,oBAAE,CAAC,kBAAkB,CAAC,KAAK;oBACrC,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,IAAI,EAAE,WAAI,GAAG,CAAC,IAAI,MAAU;iBAC/B,CAAC,CAAC;gBACH,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;gBACzC,OAAO,IAAI,CAAC;aACf;QACL,CAAC;IAjBD,CAiBC,CAAC;AACV,CAAC,EA3CgB,eAAe,+BAAf,eAAe,QA2C/B;AAED,IAAM,kBAAkB,GAAG,UAAC,KAAU;IAClC,OAAA,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,kBAAkB;QAC7C,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;AAJjC,CAIiC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "5.0.0-dev.20230830",
3
+ "version": "5.0.0",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -1,4 +1,9 @@
1
1
  export type TagBase<Props extends TagBase.IProps<any, any, any, any, any>> = {
2
+ /**
3
+ * This is a dummy property for compilation.
4
+ *
5
+ * It does not mean anything in runtime.
6
+ */
2
7
  "typia.tag"?: Props;
3
8
  };
4
9
  export namespace TagBase {
@@ -13,10 +18,51 @@ export namespace TagBase {
13
18
  },
14
19
  Exclusive extends boolean | string[],
15
20
  > {
21
+ /**
22
+ * Target type.
23
+ *
24
+ * If user tries to adapt this tag to a different type, it would be a compile
25
+ * error.
26
+ *
27
+ * For example, you've configured target type as `string`, but user adapted it
28
+ * onto a `number` type (`number & YourCustomTag<Value>`), then it would be
29
+ * blocked by TypeScript compiler.
30
+ */
16
31
  target: Target;
32
+
33
+ /**
34
+ * What kind of tag is this?
35
+ */
17
36
  kind: Kind;
37
+
38
+ /**
39
+ * Value to be configured by user.
40
+ */
18
41
  value: Value;
42
+
43
+ /**
44
+ * Validation script.
45
+ *
46
+ * This script would be inserted into the generated validation function.
47
+ * In here script, target variable name must be `$input`. The variable name
48
+ * `$input` would be transformed to the suitable when compilation.
49
+ *
50
+ * Also, If you've take a mistake on this script, compile error would be
51
+ * occured. So, define it with confidence. Compiler will block all your
52
+ * mistakes.
53
+ */
19
54
  validate: Validate;
55
+
56
+ /**
57
+ * Exclusive option.
58
+ *
59
+ * If this property configured as `true`, same {@link kind} tag cannot be
60
+ * duplicated in the target type. Otherwise, if you've configured this
61
+ * property as string array, all of the {@link kind} value assigned
62
+ * tags cannot be compatible in the target type.
63
+ *
64
+ * @default false
65
+ */
20
66
  exclusive?: Exclusive | string[];
21
67
  }
22
68
  }
@@ -20,14 +20,12 @@ export namespace FileTransformer {
20
20
  const iterate_node =
21
21
  (project: IProject) =>
22
22
  (context: ts.TransformationContext) =>
23
- (node: ts.Node): ts.Node => {
24
- const changed: ts.Node | null = try_transform_node(project)(node);
25
- return ts.visitEachChild(
26
- changed ?? node,
23
+ (node: ts.Node): ts.Node =>
24
+ ts.visitEachChild(
25
+ try_transform_node(project)(node) ?? node,
27
26
  (child) => iterate_node(project)(context)(child),
28
27
  context,
29
28
  );
30
- };
31
29
 
32
30
  const try_transform_node =
33
31
  (project: IProject) =>