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/runtime-types.md
+32-20Lines changed: 32 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,7 @@
3
3
End-to-end typing is a common way to ensure correctness across the frontend
4
4
and backend, but it's not the only way. Tools like Typelizer annotate types in
5
5
Ruby and regenerate them in TypeScript, but now you're learning two different
6
-
type languages and wondering how one maps to the other. TypeScript is just so
7
-
much more expressive. It has union types, mapped types, conditional types, and
8
-
generics that Ruby's type systems can't match.
6
+
type languages and wondering how one maps to the other.
9
7
10
8
Superglue takes a different approach, a typescript first approach. Instead of
11
9
end-to-end typing, we use
@@ -15,10 +13,9 @@ what the component needs (a header, a list of posts, each with a title and
15
13
body) via `useContent<T>()`. Then you build the props template to fulfill it.
16
14
The UI shape comes first, the business logic follows.
17
15
18
-
You can use any runtime type validation library you like. Superglue includes
19
-
experimental support for [Deepkit](https://deepkit.io/), which validates your
20
-
server responses against your TypeScript types during development. Write the
21
-
type, load the page, and the errors will guide you.
16
+
Superglue ships an experimental [Deepkit](https://deepkit.io/) plugin that
17
+
validates your server responses against your TypeScript types during
18
+
development. Write the type, load the page, and the errors will guide you.
22
19
23
20
## Getting started with Deepkit
24
21
@@ -28,27 +25,42 @@ To get started, run the installation generator with the typescript flag.
28
25
rails g superglue:install --typescript
29
26
```
30
27
31
-
The installation generator will add
28
+
The installation generator will ask if you'd like to enable Deepkit and set up
29
+
the build plugin for your bundler. If you prefer to set it up manually, add the
30
+
plugin to your build config:
32
31
33
-
1. a [esbuild plugin](https://github.com/thoughtbot/superglue_rails/blob/af7edd35d3ed211822663ac21a5c9910abcc6d88/lib/generators/superglue/install/templates/esbuild/plugin.js) that enables deepkit to work with Superglue
34
-
2. a [build.mjs](https://github.com/thoughtbot/superglue_rails/blob/af7edd35d3ed211822663ac21a5c9910abcc6d88/lib/generators/superglue/install/templates/ts/build.mjs), a esbuild node script that builds your application.
35
-
3. And setup deepkit to work with esbuild. If you are using [vite](./recipes/vite.md) or bun with superglue, please use [deepkit/vite](https://deepkit.io/en/documentation/package/vite) or [deepkit/bun](https://deepkit.io/en/documentation/package/bun) plugins.
0 commit comments