You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/eden/installation.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ client.
90
90
```
91
91
92
92
## Gotcha
93
-
Sometimes Eden may not infer type from Elysia correctly, the following are the most common workaround to fix Eden type inference.
93
+
Sometimes, Eden may not infer types from Elysia correctly, the following are the most common workarounds to fix Eden type inference.
94
94
95
95
### Type Strict
96
96
Make sure to enable strict mode in **tsconfig.json**
@@ -103,9 +103,9 @@ Make sure to enable strict mode in **tsconfig.json**
103
103
```
104
104
105
105
### Unmatch Elysia version
106
-
Eden depends Elysia class to import Elysia instance and infers type correctly.
106
+
Eden depends on Elysia class to import Elysia instance and infer types correctly.
107
107
108
-
Make sure that both client and server have a matching Elysia version.
108
+
Make sure that both client and server have the matching Elysia version.
109
109
110
110
You can check it with [`npm why`](https://docs.npmjs.com/cli/v10/commands/npm-explain) command:
111
111
@@ -135,12 +135,12 @@ node_modules/elysia
135
135
136
136
137
137
### TypeScript version
138
-
Elysia uses newer features and syntax of TypeScript to infer types in a the most performant way. Features like Const Generic and Template Literal are heavily used.
138
+
Elysia uses newer features and syntax of TypeScript to infer types in the most performant way. Features like Const Generic and Template Literal are heavily used.
139
139
140
140
Make sure your client has a **minimum TypeScript version if >= 5.0**
141
141
142
142
### Method Chaining
143
-
To make Eden works, Elysia must be using**method chaining**
143
+
To make Eden work, Elysia must use**method chaining**
144
144
145
145
Elysia's type system is complex, methods usually introduce a new type to the instance.
146
146
@@ -156,9 +156,9 @@ new Elysia()
156
156
.get('/', ({ store: { build } }) =>build)
157
157
.listen(3000)
158
158
```
159
-
Using this, **state** now returns a new **ElysiaInstance** type, introducing **build** into store and replace the current one.
159
+
Using this, **state** now returns a new **ElysiaInstance** type, introducing **build** into store replacing the current one.
160
160
161
-
Without using method chaining, Elysia doesn't save the new type when introduced, leading to no type inference.
161
+
Without method chaining, Elysia doesn't save the new type when introduced, leading to no type inference.
162
162
```typescript twoslash
163
163
// @errors: 2339
164
164
import { Elysia } from'elysia'
@@ -173,14 +173,14 @@ app.listen(3000)
173
173
```
174
174
175
175
### Type Definitions
176
-
If you are using a Bun specific feature like `Bun.file` or similar API and return it from a handler, you may need to install Bun type definitions to the client as well.
176
+
If you are using a Bun specific feature, like `Bun.file` or similar API and return it from a handler, you may need to install Bun type definitions to the client as well.
177
177
178
178
```bash
179
179
bun add -d @types/bun
180
180
```
181
181
182
182
### Path alias (monorepo)
183
-
If you are using path alias in your monorepo, make sure that frontend are able to resolve the path as same as backend.
183
+
If you are using path alias in your monorepo, make sure that frontend is able to resolve the path as same as backend.
184
184
185
185
::: tip
186
186
Setting up path alias in monorepo is a bit tricky, you can fork our example template: [Kozeki Template](https://github.com/SaltyAom/kozeki-template) and modify it to your needs.
@@ -211,7 +211,7 @@ const app = new Elysia()
211
211
exporttypeapp=typeofapp
212
212
```
213
213
214
-
You **must** make sure that your frontend code is able to resolve the same path alias otherwise type inference will be resolved as any.
214
+
You **must** make sure that your frontend code is able to resolve the same path alias. Otherwise, type inference will be resolved as any.
215
215
216
216
```typescript
217
217
import { treaty } from'@elysiajs/eden'
@@ -225,7 +225,7 @@ import { a, b } from '@/controllers'
225
225
226
226
To fix this, you must make sure that path alias is resolved to the same file in both frontend and backend.
227
227
228
-
So you must change the path alias in **tsconfig.json** to:
228
+
So, you must change the path alias in **tsconfig.json** to:
229
229
```json
230
230
{
231
231
"compilerOptions": {
@@ -244,7 +244,7 @@ import { a, b } from '@/controllers'
244
244
```
245
245
246
246
#### Scope
247
-
We recommended to add a **scope** prefix for each modules in your monorepo to avoid any confusion and conflict that may happen.
247
+
We recommended adding a **scope** prefix for each module in your monorepo to avoid any confusion and conflict that may happen.
248
248
249
249
```json
250
250
{
@@ -258,12 +258,12 @@ We recommended to add a **scope** prefix for each modules in your monorepo to av
258
258
}
259
259
```
260
260
261
-
Then you can import the module like this:
261
+
Then, you can import the module like this:
262
262
```typescript
263
263
// Should work in both frontend and backend and not return `any`
264
264
import { a, b } from'@backend/controllers'
265
265
```
266
266
267
-
We recommended creating a **single tsconfig.json** that define a `baseUrl` as the root of your repo, provide a path according to the module location, and create a **tsconfig.json** for each module that inherits the root **tsconfig.json** which has the path alias.
267
+
We recommend creating a **single tsconfig.json** that defines a `baseUrl` as the root of your repo, provide a path according to the module location, and create a **tsconfig.json** for each module that inherits the root **tsconfig.json** which has the path alias.
268
268
269
-
You may find a working example of in this [path alias example repo](https://github.com/SaltyAom/elysia-monorepo-path-alias) or [Kozeki Template](https://github.com/SaltyAom/kozeki-template)
269
+
You may find a working example of in this [path alias example repo](https://github.com/SaltyAom/elysia-monorepo-path-alias) or [Kozeki Template](https://github.com/SaltyAom/kozeki-template).
0 commit comments