Skip to content

Commit

Permalink
chore(docs): update more WIT representations
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Adossi <[email protected]>
  • Loading branch information
vados-cosmonic committed Feb 5, 2025
1 parent 68bc90d commit 4f00eb4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion docs/src/wit-type-representations.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
# WIT Type Representations

Similar to any other guest langauge, there are multiple type systems in play when dealing with JS WebAssembly components. Types represented in [WebAssembly Interface Types ("WIT")][wit] must be converted down
Similar to any other guest langauge, there are multiple type systems in play when dealing with JS WebAssembly components.

Types represented in [WebAssembly Interface Types ("WIT")][wit] must be converted down to types that are familiar for Javascript,
and [Typescript][ts] (if dealing with `jco types` or `jco guest-types` subcommands).

This document details the type representations and usage for types that are defined in WIT and built into components.

[wit]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
[ts]: https://www.typescriptlang.org/

## Basic types

Here is a basic table of conversions between WIT types and JS types:

More complicated types that are built into WIT but require more work to translate are explained below.

| WIT type | JS Type |
|----------|-----------|
| `u8` | `number` |
| `u16` | `number` |
| `u32` | `number` |
| `u64` | `number` |
| `s8` | `number` |
| `s16` | `number` |
| `s32` | `number` |
| `s64` | `number` |
| `f32` | `number` |
| `f64` | `number` |
| `bool` | `boolean` |
| `char` | `string` |
| `string` | `string` |

## List (`list`)

### WIT Syntax
Expand Down

0 comments on commit 4f00eb4

Please sign in to comment.