Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

Auto generation of idiomatic bindings between Reason and #"true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true">rescript-lang.org/docs/gentype/latest/introduction

License

NotificationsYou must be signed in to change notification settings

rescript-association/genType

Repository files navigation

⚠️ This project has moved into therescript-compiler and is part ofrescript@10.1 and above.

Please report any issues regarding ReScript -> TypeScript compilation in thecompiler issue tracker.

ReScript genType

The latest genType docs have been migrated to theReScript website.

genType lets you exportReScript values and types to use in JavaScript, and import JavaScript values and types into ReScript, idiomatically. Converter functions between the two representations are generated based on the type of the value. The converters can be generated in vanilla JavaScript, or inTypeScript /Flow for a type-safe idiomatic interface.In particular, conversion ofReasonReact components both ways is supported, with automatic generation of the wrappers.

Project status.

SeeChanges.md for a complete list of features, fixes, and changes for each release.

Requirements

rescript 9.1.0 or higher: usegenType 3.45.0 or higher.

bs-platform 9.0.1 or higher: usegenType 3.44.0 or higher.

bs-platform 9.0.0 or higher: usegenType 3.43.0 or higher.

bs-platform 8.3.0 or higher: usegenType 3.36.0 or higher.

bs-platform 8.2.0 or higher: usegenType 3.31.0 or higher.

bs-platform 8.1.1 or higher: usegenType 3.27.0 or higher.

bs-platform 8.0.0 or higher: usegenType 3.26.0 or higher.

bs-platform 7.3.0 or higher: usegenType 3.18.0 or higher.

bs-platform 7.2.0 or higher: usegenType 3.13.0 or higher.

bs-platform 7.0.2 or higher: usegenType 3.8.0 or higher.

bs-platform 7.0.0 or higher: usegenType 3.2.0 or higher.

bs-platform 6.2.0 or higher: usegenType 3.0.0 or higher.

bs-platform 5.2.0 or higher: usegenType 2.40.0 or higher.

bs-platform 5.0.x and 5.1.x: usegenType 2.17.0 or higher.

For earlier versions, see the olderREADME.

Installation

Install the binaries vianpm:

npm install --save-dev gentype# Test running gentypenpx gentype --help

Add agentypeconfig section to yourbsconfig.json (SeeConfiguration for details):

"gentypeconfig": {    "language": "untyped",    "shims": {},    "debug": {      "all": false,      "basic": false    }}

For runninggentype with ReScript vianpm workflow, add following script in yourpackage.json:

scripts: {  "build": "rescript",  "clean": "rescript clean"}

Note: With genType < 2.17.0 or ReScript < 5.0.0, one has to set environment variableBS_CMT_POST_PROCESS_CMD. See the olderREADME.

With this configuration, ReScript will callgentype for each newly built file. You might want to clean your build artifacts before usage:npx bsb -clean-world (otherwise there might be cached values and no.gen.js files are generated).

Check out theExamples for detailed setups (TypeScript, Flow and Plain JavaScript).

Adding shims (TypeScript & Flow)

Configure your shim files in your"gentypeconfig" inbsconfig.json, and add relevant.shims.js files in a directory which is visible by ReScript e.g.src/shims/. An example shim to export ReactEvent can be foundhere.

Testing the whole setup

Open any relevant*.res file and add@genType annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g.Hooks.res.

Save the file and rebuild the project with ReScript. You should now see a*.gen.tsx (for TypeScript, or*.gen.js for Flow) file with the same name (e.g.MyComponent.res ->MyComponent.gen.tsx).

Any values exported fromMyComponent.res can then be imported from JS. For example:

importMyComponentfrom"./components/MyComponent.gen";

Examples

We prepared some examples to give you an idea on how to integrategenType in your own project. Check out the READMEs of the listed projects.

Please make sure to build genType before trying to build the examples.

Documentation

Full documentation can be foundhere.

(In case you are looking for the previous version of the docs, here is anolder version of this README)

Development/Contributing

Please check out ourdevelopment instructions.

About

Auto generation of idiomatic bindings between Reason and #"true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true">rescript-lang.org/docs/gentype/latest/introduction

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors23

Languages


[8]ページ先頭

©2009-2025 Movatter.jp