Skip to content

Commit a0b68b0

Browse files
Merge pull request #755 from fhammerschmidt/gentype-to-main-docs
Integrate genType as 'TypeScript Interop' chapter into main docs
2 parents 348d0b2 + aae07eb commit a0b68b0

23 files changed

+325
-737
lines changed

data/sidebar_manual_latest.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"use-illegal-identifier-names",
5252
"generate-converters-accessors",
5353
"browser-support-polyfills",
54-
"libraries"
54+
"libraries",
55+
"typescript-integration"
5556
],
5657
"Build System": [
5758
"build-overview",
+5-44
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
---
22
id: "gentype-decorator"
3-
keywords: ["gentype", "decorator", "typescript", "flow"]
3+
keywords: ["gentype", "decorator", "typescript"]
44
name: "@genType"
55
summary: "This is the `@genType` decorator."
66
category: "decorators"
77
---
88

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, 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.
1010

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/typescript-integration) 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.
1412

1513
### Example
1614

17-
<CodeTab labels={["ReScript", "TypeScript Output", "Flow Output"]}>
15+
<CodeTab labels={["ReScript", "TypeScript Output"]}>
1816

1917
```res
2018
@genType
@@ -59,45 +57,8 @@ export const make: React.ComponentType<{
5957
};
6058
```
6159

62-
```js
63-
/**
64-
* @flow strict
65-
* @generated from MyComponent.res
66-
* @nolint
67-
*/
68-
/* eslint-disable */
69-
// $FlowExpectedError: Reason checked type sufficiently
70-
type $any = any;
71-
72-
// $FlowExpectedError: Reason checked type sufficiently
73-
import * as React from "react";
74-
75-
const $$toRE818596289 = { Red: 0, Blue: 1 };
76-
77-
// $FlowExpectedError: Reason checked type sufficiently
78-
import * as MyComponentBS from "./MyComponent.bs";
79-
80-
export type color = "Red" | "Blue";
81-
82-
// Type annotated function components are not checked by Flow, but typeof() works.
83-
const make$$forTypeof = function (_: {|
84-
+color: color,
85-
+name: string,
86-
|}): React$Node {
87-
return null;
88-
};
89-
90-
export type Props = {| +color: color, +name: string |};
91-
92-
export const make: typeof make$$forTypeof = function MyComponent(Arg1: $any) {
93-
const $props = { color: $$toRE818596289[Arg1.color], name: Arg1.name };
94-
const result = React.createElement(MyComponentBS.make, $props);
95-
return result;
96-
};
97-
```
98-
9960
</CodeTab>
10061

10162
### References
10263

103-
* [GenType](/docs/gentype/latest/introduction)
64+
* [TypeScript Integration](/docs/manual/latest/typescript-integration)

next.config.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ const config = {
102102
destination: "/docs/manual/v10.0.0/unboxed",
103103
permanent: true,
104104
},
105+
{
106+
source: "/docs/gentype/latest/introduction",
107+
destination: "/docs/manual/latest/typescript-integration",
108+
permanent: true,
109+
},
110+
{
111+
source: "/docs/gentype/latest/getting-started",
112+
destination: "/docs/manual/latest/typescript-integration",
113+
permanent: true,
114+
},
115+
{
116+
source: "/docs/gentype/latest/usage",
117+
destination: "/docs/manual/latest/typescript-integration",
118+
permanent: true,
119+
},
120+
{
121+
source: "/docs/gentype/latest/supported-types",
122+
destination: "/docs/manual/latest/typescript-integration",
123+
permanent: true,
124+
},
105125
];
106126
},
107127
};

pages/docs/gentype/latest/getting-started.mdx

-102
This file was deleted.

pages/docs/gentype/latest/introduction.mdx

-105
This file was deleted.

0 commit comments

Comments
 (0)