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
The `@genType` decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems.
9
+
The `@genType` decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, or plain JavaScript codebases, without losing type information across different type systems.
10
10
11
-
[GenType](/docs/gentype/latest/introduction) is a code generation tool for automatically generating [TypeScript](https://www.typescriptlang.org/) / [Flow](https://flow.org/) type definitions, and JS runtime converters for non-shared ReScript values. It also features first-class support for [ReasonReact](https://reasonml.github.io/reason-react/) components.
12
-
13
-
**Note:** This decorator requires the `gentype` npm package to be installed and configured correctly. Please refer to genType's [Getting Started](/docs/gentype/latest/getting-started) section for more details.
11
+
[GenType](/docs/manual/latest/gentype-introduction) is a code generation tool for automatically generating [TypeScript](https://www.typescriptlang.org/) type definitions, and JS runtime converters for non-shared ReScript values. It also features first-class support for [rescript-react](/docs/react/latest/introduction) components.
Copy file name to clipboardExpand all lines: pages/docs/manual/latest/build-configuration.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -160,7 +160,7 @@ Generating JS files with the `.bs.js` suffix means that, on the JS side, you can
160
160
- It's immediately clear that we're dealing with a generated JS file here.
161
161
- It avoids clashes with a potential `theFile.js` file in the same folder.
162
162
- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**.
163
-
-[genType](/docs/gentype/latest/introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now.
163
+
-[genType](/docs/manual/latest/gentype-introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now.
For detailed information, head to the [Getting Started](getting-started) or [Usage](usage) section.
101
+
For detailed information, head to the [Getting Started](/docs/manual/latest/gentype-getting-started) or [Usage](/docs/manual/latest/gentype-usage) section.
@@ -39,7 +39,7 @@ The JS values are identical: there is no conversion unless the argument type nee
39
39
40
40
ReScript record values of type e.g. `{x: int}` such as `{x: 0}`, `{x: 1}`, are exported to JS values of type `{x: number}` without runtime conversion.
41
41
42
-
Since records are immutable by default, their fields will be exported to readonly property types in Flow/TS. Mutable fields are specified in ReScript by e.g. `{mutable mutableField: string}`.
42
+
Since records are immutable by default, their fields will be exported to readonly property types in TS. Mutable fields are specified in ReScript by e.g. `{mutable mutableField: string}`.
43
43
44
44
The `@as` annotation can be used to change the name of a field on the JS side of things. So e.g. `{@as("y") x: int}` is exported as JS type `{y: number}`.
45
45
@@ -50,14 +50,14 @@ If one field of the ReScript record has option type, this is exported to an opti
50
50
ReScript object values of type e.g. `{. "x":int}` such as `{"x": 0}`, `{"x": 1}`, `{"x": 2}`, are exported as identical JS object values `{x:0}`, `{x:1}`, `{x:2}`. This requires no conversion. So they are exported to JS values of type `{x:number}`.
51
51
A conversion is required only when the type of some field requires conversions.
52
52
53
-
Since objects are immutable by default, their fields will be exported to readonly property types in Flow/TS. Mutable fields are specified in ReScript by e.g. `{ @set "mutableField": string }`.
53
+
Since objects are immutable by default, their fields will be exported to readonly property types in TS. Mutable fields are specified in ReScript by e.g. `{ @set "mutableField": string }`.
54
54
55
55
It is possible to mix object and option types, so for example the ReScript type `{. "x":int, "y":option<string>}` exports to JS type `{x:number, ?y: string}`, requires no conversion, and allows option pattern matching on the ReScript side.
56
56
57
57
## Tuples
58
58
59
59
ReScript tuple values of type e.g. `(int, string)` are exported as identical JS values of type `[number, string]`. This requires no conversion, unless one of types of the tuple items does.
60
-
While the type of ReScript tuples is immutable, there's currently no mature enforcement in TS/Flow, so they're currenty exported to mutable tuples.
60
+
While the type of ReScript tuples is immutable, there's currently no mature enforcement in TS, so they're currenty exported to mutable tuples.
61
61
62
62
## Variants
63
63
@@ -96,7 +96,7 @@ Arrays with elements of ReScript type `t` are exported to JS arrays with element
96
96
97
97
Immutable arrays are supported with the additional ReScript library
98
98
[ImmutableArray.res/.resi](https://github.com/reason-association/genType/tree/master/examples/typescript-react-example/src/ImmutableArray.resi), which currently needs to be added to your project.
99
-
The type `ImmutableArray.t<+'a>` is covariant, and is mapped to readonly array types in TS/Flow. As opposed to TS/Flow, `ImmutableArray.t` does not allow casting in either direction with normal arrays. Instead, a copy must be performed using `fromArray` and `toArray`.
99
+
The type `ImmutableArray.t<+'a>` is covariant, and is mapped to readonly array types in TS. As opposed to TS, `ImmutableArray.t` does not allow casting in either direction with normal arrays. Instead, a copy must be performed using `fromArray` and `toArray`.
100
100
101
101
## Functions and Function Components
102
102
@@ -117,7 +117,7 @@ let make = (~name) => React.string(name);
117
117
118
118
## Imported Types
119
119
120
-
It's possible to import an existing TS/Flow type as an opaque type in ReScript. For example,
120
+
It's possible to import an existing TS type as an opaque type in ReScript. For example,
Copy file name to clipboardExpand all lines: pages/docs/manual/latest/shared-data-types.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -41,4 +41,4 @@ Unlike most compiled-to-js languages, in ReScript, **you don't need to write dat
41
41
42
42
Many of these are stable, which means that you can still serialize/deserialize them as-is without manual conversions. But we discourage actively peeking into their structure otherwise.
43
43
44
-
These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript/Flow integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand.
44
+
These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand.
Copy file name to clipboardExpand all lines: pages/docs/manual/v10.0.0/build-configuration.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -161,7 +161,7 @@ Generating JS files with the `.bs.js` suffix means that, on the JS side, you can
161
161
- It's immediately clear that we're dealing with a generated JS file here.
162
162
- It avoids clashes with a potential `theFile.js` file in the same folder.
163
163
- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**.
164
-
-[genType](/docs/gentype/latest/introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now.
164
+
-[genType](/docs/manual/latest/gentype-introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now.
Copy file name to clipboardExpand all lines: pages/docs/manual/v9.0.0/build-configuration.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -157,7 +157,7 @@ Generating JS files with the `.bs.js` suffix means that, on the JS side, you can
157
157
- It's immediately clear that we're dealing with a generated JS file here.
158
158
- It avoids clashes with a potential `theFile.js` file in the same folder.
159
159
- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**.
160
-
-[genType](/docs/gentype/latest/introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now.
160
+
-[genType](/docs/manual/latest/gentype-introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now.
0 commit comments