From a116c4a3d2e4ec56e8a938df04e2a232447494b1 Mon Sep 17 00:00:00 2001 From: Miles Burton Date: Wed, 24 Apr 2024 17:28:02 +0100 Subject: [PATCH] Added additional clarification, fixed typeos --- website/pages/docs/setup.mdx | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/website/pages/docs/setup.mdx b/website/pages/docs/setup.mdx index cceffe00ec..3efca11e52 100644 --- a/website/pages/docs/setup.mdx +++ b/website/pages/docs/setup.mdx @@ -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) @@ -71,20 +71,13 @@ yarn typia generate \ -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. @@ -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 depepdency. 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 { @@ -206,9 +199,9 @@ At first, install `typia` as depepdency. 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} { @@ -245,9 +238,9 @@ yarn prepare -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. @@ -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. @@ -570,4 +565,4 @@ After install `typia` like above, you have to modify `project.json` on each app }, ... } -``` \ No newline at end of file +```