typia 3.6.0-dev.20230225 → 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.
Files changed (2) hide show
  1. package/README.md +56 -38
  2. package/package.json +1 -2
package/README.md CHANGED
@@ -54,34 +54,55 @@ Thanks for your support.
54
54
 
55
55
  Your donation would encourage `typia` development.
56
56
 
57
- [![Backers](https://opencollective.com/typia/backers.svg?avatarHeight=75&width=600))](https://opencollective.com/typia)
57
+ [![Sponsers](https://opencollective.com/typia/badge.svg?avatarHeight=75&width=600))](https://opencollective.com/typia)
58
58
 
59
59
 
60
60
 
61
61
 
62
62
  ## Setup
63
- ### Setup Wizard
63
+ ### Transformation (stable)
64
64
  ```bash
65
65
  npx typia setup
66
66
  ```
67
67
 
68
- Just type `npx typia setup`, that's all.
68
+ AOT (Ahead of Time) compilation mode.
69
69
 
70
- If you've installed [ttypescript](https://github.com/cevek/ttypescript) during setup, you should compile `typia` utilization code through `ttsc` command, instead of `tsc`.
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
+
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
+
74
+ ```typescript
75
+ // TYPESCRIPT CODE
76
+ import typia from "typia";
77
+ export const check = typia.createIs<string | null>();
78
+
79
+ // COMPILED JAVASCRIPT CODE
80
+ export const check = (input) => "string" === typeof input || null === input;
81
+ ```
82
+
83
+ ![Typia Setup Wizard](https://user-images.githubusercontent.com/13158709/221402176-83b1bfe8-bc8f-4fba-9d83-6adbdfce5c8c.png)
84
+
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
+
87
+ If [ttypescript](https://github.com/cevek/ttypescript), you should compile through `ttsc` command, instead of using `tsc`.
88
+
89
+ Otherwise, you've chosen [ts-patch](https://github.com/nonara/ts-patch), you can use original `tsc` command. However, [ts-patch](https://github.com/nonara/ts-patch) hacks `node_modules/typescript` source code. Also, whenever update `typescrtip` version, you have to run `npm run prepare` command repeatedly.
90
+
91
+ By the way, when using [@nest/cli](https://nestjs.com), you must just choose [ts-patch](https://github.com/nonara/ts-patch).
71
92
 
72
93
  ```bash
94
+ #--------
95
+ # TTYPESCRIPT
96
+ #--------
73
97
  # COMPILE THROUGH TTYPESCRIPT
74
98
  npx ttsc
75
99
 
76
100
  # RUN TS-NODE WITH TTYPESCRIPT
77
101
  npx ts-node -C ttypescript src/index.ts
78
- ```
79
-
80
- Otherwise, you've chosen [ts-patch](https://github.com/nonara/ts-patch), you can use original `tsc` command. However, [ts-patch](https://github.com/nonara/ts-patch) hacks `node_modules/typescript` source code. Also, whenever update `typescript` version, you've to run `npm run prepare` command repeatedly.
81
102
 
82
- By the way, when using `@nest/cli`, you must just choose [ts-patch](https://github.com/nonara/ts-patch)
83
-
84
- ```bash
103
+ #--------
104
+ # TS-PATCH
105
+ #--------
85
106
  # USE ORIGINAL TSC COMMAND
86
107
  tsc
87
108
  npx ts-node src/index.ts
@@ -91,40 +112,37 @@ npm install --save-dev typescript@latest
91
112
  npm run prepare
92
113
  ```
93
114
 
94
- ### Manual Setup
95
- If you want to install and setup `typia` manually, read [Guide Documents - Setup](https://github.com/samchon/typia/wiki/Setup).
115
+ ### Generation (beta)
116
+ ```bash
117
+ # INSTALL TYPIA
118
+ npm install --save typia
96
119
 
97
- - [Setup Wizard](https://github.com/samchon/typia/wiki/Setup#setup-wizard)
98
- - [NPM Packages](https://github.com/samchon/typia/wiki/Setup#npm-packages)
99
- - [`tsconfig.json`](https://github.com/samchon/typia/wiki/Setup#tsconfigjson)
100
- - [vite](https://github.com/samchon/typia/wiki/Setup#vite)
101
- - [webpack](https://github.com/samchon/typia/wiki/Setup#webpack)
120
+ # GENERATE TRANSFORMED TYPESCRIPT CODES
121
+ npx typia generate \
122
+ --input src/templates \
123
+ --output src/generated
124
+ ```
102
125
 
103
- ### Vite
104
- When you want to setup `typia` on your frontend project with [`vite`](https://vitejs.dev/), just configure `vite.config.ts` like below.
126
+ > For frontend projects.
105
127
 
106
- Also, don't forget running [Setup Wizard](#setup-wizard) before.
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.
107
129
 
108
- If you've chosen [ts-patch](https://github.com/nonara/ts-patch) compiler, just call only `typescript()` function.
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.
109
131
 
110
132
  ```typescript
111
- import { defineConfig } from "vite";
112
- import react from "@vitejs/plugin-react";
113
- import typescript from "@rollup/plugin-typescript";
114
- import ttsc from "ttypescript";
115
-
116
- // https://vitejs.dev/config/
117
- export default defineConfig({
118
- plugins: [
119
- react(),
120
- // when using "ttypescript"
121
- typescript({
122
- typescript: ttsc,
123
- }),
124
- // otherwise using "ts-patch"
125
- typescript()
126
- ]
127
- });
133
+ //--------
134
+ // src/templates/check.ts
135
+ //--------
136
+ import typia from "typia";
137
+ export const check = typia.createIs<string | null>();
138
+
139
+ //--------
140
+ // src/generated/check.ts
141
+ //--------
142
+ import typia from "typia";
143
+ export const check =
144
+ (input: unknown): input is string | null
145
+ => "string" === typeof input || null === input;
128
146
  ```
129
147
 
130
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "3.6.0-dev.20230225",
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": {