typia 3.6.0-dev.20230226 → 3.6.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 +14 -10
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -67,9 +67,9 @@ npx typia setup
|
|
|
67
67
|
|
|
68
68
|
AOT (Ahead of Time) compilation mode.
|
|
69
69
|
|
|
70
|
-
When you write a TypeScript code calling `typia.createIs<string | null>()` function and compile
|
|
70
|
+
When you write a TypeScript code calling `typia.createIs<string | null>()` function and compile it, `typia` will write optimal validation code like below, for the `string | null` type. This is the transform mode performing AOT (Ahead of Time) compilation.
|
|
71
71
|
|
|
72
|
-
As long as you're using standard TypeScript compiler, I just recommend you to use this transform mode. Otherwise, you're using non-standard compiler like [SWC](https://swc.rs/) or [Babel](https://babeljs.io/) (mostly designed for frontend development), you've to use the generation mode instead.
|
|
72
|
+
<!-- As long as you're using standard TypeScript compiler, I just recommend you to use this transform mode. Otherwise, you're using non-standard compiler like [SWC](https://swc.rs/) or [Babel](https://babeljs.io/) (mostly designed for frontend development), you've to use the [generation mode](#generation-beta) instead. -->
|
|
73
73
|
|
|
74
74
|
```typescript
|
|
75
75
|
// TYPESCRIPT CODE
|
|
@@ -82,7 +82,7 @@ export const check = (input) => "string" === typeof input || null === input;
|
|
|
82
82
|
|
|
83
83
|

|
|
84
84
|
|
|
85
|
-
By the way, to use
|
|
85
|
+
By the way, to use this transform mode, you've install one onf them; [ttypescript](https://github.com/cevek/ttypescript) or [ts-patch](https://github.com/nonara/ts-patch).
|
|
86
86
|
|
|
87
87
|
If [ttypescript](https://github.com/cevek/ttypescript), you should compile through `ttsc` command, instead of using `tsc`.
|
|
88
88
|
|
|
@@ -91,18 +91,18 @@ Otherwise, you've chosen [ts-patch](https://github.com/nonara/ts-patch), you can
|
|
|
91
91
|
By the way, when using [@nest/cli](https://nestjs.com), you must just choose [ts-patch](https://github.com/nonara/ts-patch).
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
|
|
94
|
+
#--------
|
|
95
95
|
# TTYPESCRIPT
|
|
96
|
-
|
|
96
|
+
#--------
|
|
97
97
|
# COMPILE THROUGH TTYPESCRIPT
|
|
98
98
|
npx ttsc
|
|
99
99
|
|
|
100
100
|
# RUN TS-NODE WITH TTYPESCRIPT
|
|
101
101
|
npx ts-node -C ttypescript src/index.ts
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
#--------
|
|
104
104
|
# TS-PATCH
|
|
105
|
-
|
|
105
|
+
#--------
|
|
106
106
|
# USE ORIGINAL TSC COMMAND
|
|
107
107
|
tsc
|
|
108
108
|
npx ts-node src/index.ts
|
|
@@ -123,24 +123,28 @@ npx typia generate \
|
|
|
123
123
|
--output src/generated
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
> For frontend projects.
|
|
127
|
+
|
|
128
|
+
If you're using non-standard TypeScript compiler like [SWC](https://swc.rs/) or [Babel](https://babeljs.io/), you can't use [transform mode](#transformation-stable). Instead, you can utilize the generation mode. Install `typia` through `npm install` command and run `typia generate` command like above.
|
|
127
129
|
|
|
128
130
|
The generator of `typia` reads your TypeScript code of `--input` and writes transformed TypeScript code into the `--output` directory. However, as this feature generates duplicated TypeScript code even even not perfectly stable like [transform mode](#transformation-stable), I recommend you to use generation mode only when you're using non-standard TypeScript compiler.
|
|
129
131
|
|
|
130
132
|
```typescript
|
|
133
|
+
//--------
|
|
131
134
|
// src/templates/check.ts
|
|
135
|
+
//--------
|
|
132
136
|
import typia from "typia";
|
|
133
137
|
export const check = typia.createIs<string | null>();
|
|
134
138
|
|
|
139
|
+
//--------
|
|
135
140
|
// src/generated/check.ts
|
|
141
|
+
//--------
|
|
136
142
|
import typia from "typia";
|
|
137
143
|
export const check =
|
|
138
144
|
(input: unknown): input is string | null
|
|
139
145
|
=> "string" === typeof input || null === input;
|
|
140
146
|
```
|
|
141
147
|
|
|
142
|
-
> For reference, most of frontend projects are using non-standard TypeScript compiler like [SWC](https://swc.rs/) or [Babel](https://babeljs.io/) (mostly designed for frontend development). Therefore, I just recomend you to use the generation mode when developing frontend project.
|
|
143
|
-
|
|
144
148
|
|
|
145
149
|
|
|
146
150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "3.6.0
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://github.com/samchon/typia#readme",
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"ttypescript": ">= 1.5.15",
|
|
68
67
|
"typescript": ">= 4.5.2"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|