rescript-association / Gentype

Licence: mit
Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
reason
219 projects
types
53 projects
flowtype
47 projects
bucklescript
41 projects

Projects that are alternatives of or similar to Gentype

genTypeScript
Auto generation of type-safe bindings between Reason and Typescript.
Stars: ✭ 75 (-89.02%)
Mutual labels:  type-safety, reasonml
Learn Graphql
Real world GraphQL tutorials for frontend developers with deadlines!
Stars: ✭ 586 (-14.2%)
Mutual labels:  reasonml
Hazel
Hazel, a live functional programming environment with typed holes
Stars: ✭ 340 (-50.22%)
Mutual labels:  reasonml
Renature
A physics-based animation library for React focused on modeling natural world forces.
Stars: ✭ 408 (-40.26%)
Mutual labels:  reasonml
Fnm
🚀 Fast and simple Node.js version manager, built in Rust
Stars: ✭ 6,102 (+793.41%)
Mutual labels:  reasonml
Brisk
✨Cross-platform set of tools for building native UIs with Reason/OCaml
Stars: ✭ 518 (-24.16%)
Mutual labels:  reasonml
Structopt
Parse command line arguments by defining a struct
Stars: ✭ 323 (-52.71%)
Mutual labels:  type-safety
Reason Scripts
🔰 Create a ReasonML and React development environment
Stars: ✭ 644 (-5.71%)
Mutual labels:  reasonml
Swift Nonempty
🎁 A compile-time guarantee that a collection contains a value.
Stars: ✭ 585 (-14.35%)
Mutual labels:  type-safety
Reductive
Redux in Reason
Stars: ✭ 405 (-40.7%)
Mutual labels:  reasonml
Sketch Sh
Sketch.sh - Online Code Editor and ReasonML community
Stars: ✭ 403 (-41%)
Mutual labels:  reasonml
Reason Tools
Adds Reason to the browser
Stars: ✭ 366 (-46.41%)
Mutual labels:  reasonml
Reasonablytyped
💠 Converts Flow and TypeScript definitions to Reason interfaces
Stars: ✭ 525 (-23.13%)
Mutual labels:  reasonml
Graphaello
A Tool for Writing Declarative, Type-Safe and Data-Driven Applications in SwiftUI using GraphQL
Stars: ✭ 355 (-48.02%)
Mutual labels:  type-safety
Reason React Hacker News
hacker news mobile app made with reason react
Stars: ✭ 591 (-13.47%)
Mutual labels:  reasonml
Graphql ppx
GraphQL PPX rewriter for Bucklescript/ReasonML
Stars: ✭ 325 (-52.42%)
Mutual labels:  reasonml
Crra
Create Reason React App
Stars: ✭ 384 (-43.78%)
Mutual labels:  reasonml
Topshell
TopShell - a purely functional, reactive scripting language
Stars: ✭ 422 (-38.21%)
Mutual labels:  type-safety
Oni2
Native, lightweight modal code editor
Stars: ✭ 6,704 (+881.55%)
Mutual labels:  reasonml
Reason React
Stars: ✭ 636 (-6.88%)
Mutual labels:  reasonml

ReScript genType

Status master (v3.*): Build Status

The latest genType docs have been migrated to the ReScript website.

genType lets you export ReScript 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 in TypeScript / Flow for a type-safe idiomatic interface. In particular, conversion of ReasonReact components both ways is supported, with automatic generation of the wrappers.

Project status.

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

Requirements

bs-platform 9.0.1 or higher: use genType 3.44.0 or higher.

bs-platform 9.0.0 or higher: use genType 3.43.0 or higher.

bs-platform 8.3.0 or higher: use genType 3.36.0 or higher.

bs-platform 8.2.0 or higher: use genType 3.31.0 or higher.

bs-platform 8.1.1 or higher: use genType 3.27.0 or higher.

bs-platform 8.0.0 or higher: use genType 3.26.0 or higher.

bs-platform 7.3.0 or higher: use genType 3.18.0 or higher.

bs-platform 7.2.0 or higher: use genType 3.13.0 or higher.

bs-platform 7.0.2 or higher: use genType 3.8.0 or higher.

bs-platform 7.0.0 or higher: use genType 3.2.0 or higher.

bs-platform 6.2.0 or higher: use genType 3.0.0 or higher.

bs-platform 5.2.0 or higher: use genType 2.40.0 or higher.

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

For earlier versions, see the older README.

Installation

Install the binaries via npm:

npm install --save-dev gentype

# Test running gentype
npx gentype --help

Add a gentypeconfig section to your bsconfig.json (See Configuration for details):

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

For running gentype with ReScript via npm workflow, add following script in your package.json:

scripts: {
  "build": "bsb -make-world",
  "clean": "bsb -clean-world"
}

Note: With genType < 2.17.0 or ReScript < 5.0.0, one has to set environment variable BS_CMT_POST_PROCESS_CMD. See the older README.

With this configuration, ReScript will call gentype 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 the Examples for detailed setups (TypeScript, Flow and Plain JavaScript).

Adding shims (TypeScript & Flow)

Configure your shim files in your "gentypeconfig" in bsconfig.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 found here.

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 from MyComponent.res can then be imported from JS. For example:

import MyComponent from "./components/MyComponent.gen";

Examples

We prepared some examples to give you an idea on how to integrate genType 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 found here.

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

Development/Contributing

Please check out our development instructions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].