Skip to content

Commit

Permalink
Merge pull request #1045 from milesburton/patch-1
Browse files Browse the repository at this point in the history
Added additional clarification, fixed typos
  • Loading branch information
samchon authored May 25, 2024
2 parents 34a94c6 + fe14467 commit 9ed37fd
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions website/pages/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ yarn typia setup --manager yarn

If you're using standard TypeScript compiler, you can use [transform mode](#transformation).

Just run `npx typia setup` command, then everything be prepared.
Assuming you are using [transformation mode] simply run `npx typia setup` which will provide sane defaults.

- Standard TypeScript Compiler: [Microsoft/TypeScript](https://github.com/microsoft/typescript)

Expand Down Expand Up @@ -71,20 +71,13 @@ yarn typia generate \
</Tab>
</Tabs>

Otherwise you are using non-standard TypeScript compiler, then you can't use [transformation](#transformation) mode.

Instead, you can use [generation](#generation) mode.

Run `typia generate` command with `input` directory, then transformed TypeScript files would be generated into the `output` directory.
If you are using a non-standard TypeScript compiler such as the following, you will need to fall back to [generation](#generation) mode

- Non-standard TypeScript Compilers
- [SWC](https://swc.rs)
- [ESBuild](https://esbuild.github.io/)
- [Babel](https://babeljs.io/)




## Transformation
### Concepts
AOT (Ahead of Time) compilation mode.
Expand Down Expand Up @@ -192,7 +185,7 @@ yarn add -D typescript ts-patch ts-node

If you want to install `typia` manually, just follow the steps.

At first, install `typia` as dependency. And then, install `typescript`, `ts-patch` and `ts-node` as `devDependencies`.
Firstly install `typia` as a dependency. And then, install `typescript`, `ts-patch` and `ts-node` as `devDependencies`.

```json filename="tsconfig.json" copy showLineNumbers
{
Expand All @@ -206,9 +199,9 @@ At first, install `typia` as dependency. And then, install `typescript`, `ts-pat
}
```

At second, open your `tsconfig.json` file and configure like above.
Secondly open your `tsconfig.json` file as shown above.

As `typia` generates optimal operation code through transformation, you've to configure it as a `plugin`. Also, never forget to configure `strict` (or `strictNullChecks`) to be `true`. It is essential option for modern TypeScript development.
As `typia` generates optimal operation code through transformation, it must be configured as a `plugin`. Also, never forget to configure `strict` (or `strictNullChecks`) to be `true` within your tsconfig.json `compilerOptions`. It is essential option for modern TypeScript development.

```json filename="package.json" copy showLineNumbers {2-4}
{
Expand Down Expand Up @@ -245,9 +238,9 @@ yarn prepare
</Tab>
</Tabs>

At last, open `package.json` file and configure `npm run prepare` command like above.
Finally open `package.json` file and configure `npm run prepare` command like above.

Of course, you've to run the `npm run prepare` command after the configuration.
Be sure to run `npm run prepare` once you have made these changes

For reference, [`ts-patch`](https://github.com/nonara/ts-patch) is an helper library of TypeScript compiler that supporting custom transformations by plugins. From now on, whenever you run `tsc` command, your `typia` function call statements would be transformed to the optimal operation codes in the compiled JavaScript files.

Expand Down Expand Up @@ -313,17 +306,19 @@ yarn typia generate \

For frontend projects.

If you're using non-standard TypeScript compiler, you can't use [transform mode](#transformation)
If you are using a non-standard TypeScript compiler such as the following, you will need to fall back to [generation](#generation) mode

- Non-standard TypeScript compilers:
- [SWC](https://swc.rs/) in Next.JS
- [ESBuild](https://esbuild.github.io/) in Vite
- [Babel](https://babeljs.io/) in Create-React-App

Instead, you should utilize the generation mode.
Instead you should utilise the generation mode.

Install `typia` through `npm install` command, and run `typia generate` command. Then, generator of `typia` reads your TypeScript codes of `--input`, and writes transformed TypeScript files into the `--output` directory, like below.

For clarification, the input directory should contain one or more TypeScript files which define how you want to verify your associated type assertions. Commonly you will import your TypeScript type, then export a function which validates that type. See below.

If you want to specify other TypeScript project file instead of `tsconfig.json`, you can use `--project` option.

<Tabs items={['TypeScript Source Code', 'Generated TypeScript File']}>
Expand Down

0 comments on commit 9ed37fd

Please sign in to comment.