Kyrylo Yakymenko

Reason + TypeScript with genType

Incremental adoption in existing codebases

Backend: C# and F#

Frontend: React + TypeScript




3 steps

  • Step 0: Existing TypeScript codebase
  • Step 1: Use a Reason function in JavaScript
  • Step 2: Use a Reason function in TypeScript (genType)
  • Step 3: Use a ReasonReact component in TypeScript

Step 0

Existing TypeScript codebase

Step 1

Call a function written in Reason from JavaScript

Step 2

Pull in genType

Retain type safety across languages

Step 3

Use a React component written in Reason in a TypeScript component

Starting from the "Leaves"

Other approaches

"Edges" of the system (e.g. API calls)

Good use cases

  • Domain modelling (ADTs)
  • Pattern matching
  • State machines

What to avoid

"TypeScript-Reason-TypeScript Sandwich"


GitHub, Twitter: Yakimych

Made with