• Stars
    star
    520
  • Rank 82,408 (Top 2 %)
  • Language
    OCaml
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ’  Converts Flow and TypeScript definitions to Reason interfaces

  $ npm install --global reasonably-typed

Converts TypeScript and Flow definitions to Reason interfaces
(Also maybe TypeScript definitions to Flow)


Take your Flow or TypeScript definition

// class.js
declare module 'classes' {
  declare type State = {
    id: number,
    storeName: string,
  }

  declare export class Store {
    constructor(initialState: State): Store;
    state: State;
    update(nextState: State): void;
  }
}

Run retyped

$ retyped class.js

Get Reason

/* Module classes */

type state = {. "id": float, "storeName": string };
module Store = {
  type t = {. "state": (state), "update": [@bs.meth](state => unit)};
  [@bs.new] [@bs.module "classes"] external make : state => t = "Store";
};

Docs

Examples

TypeScript

TypeScript has a similar workflow. Compile your TypeScript file with:

$ retyped my-definition.d.ts

Command-line Usage
Usage:
  $ retyped ...files

Examples:
  $ retyped file1.js file2.js file3.d.ts                                           [boolean]

Usage as a library ReasonablyTyped also exports a library for use! See the example below:
// lib-usage.js
import * as ReasonablyTyped from 'reasonably-typed'

const libSrc = fs.readFileSync('lib.js').toString()
const bsInterface = ReasonablyTyped.compile(libSrc)

format (code: string) => string

Formats a block of code using refmt

compile (code: string, filename?: string) => string

Compiles a libdef, formats the result, and handles errors cleanly

Development

See DEVELOPING and CONTRIBUTING.

Status

CircleCI

More Repositories

1

reason-scripts

πŸ”° Create a ReasonML and React development environment
JavaScript
632
star
2

material-resume

βœ’οΈ A fancy resume template
HTML
177
star
3

bs-loader

πŸ“» Bucklescript loader for Webpack and Jest
JavaScript
143
star
4

reason-dre

Declarative Bindings for ReasonML
OCaml
41
star
5

Analog

Experimental implementation of Angular components
TypeScript
32
star
6

retypes

πŸ“‡ Index of curated and automatically generated JS bindings for ReasonML
OCaml
25
star
7

ava-rethinkdb

πŸ”— RethinkDB helpers for AVA
JavaScript
23
star
8

horizon-devtools

πŸŒ… Devtools for Horizon
JavaScript
21
star
9

styled-scss

A Sass to JavaScript and React compiler
OCaml
16
star
10

Numix-Circle-OSX

βšͺ Numix Circle Icons for OS X
10
star
11

HzQL

⚑ Data Fetching for React Using Horizon 2
JavaScript
8
star
12

jadelint

πŸ‰ A linter for the Jade templating language
CoffeeScript
6
star
13

advent-of-code-2017

Advent of Code 2017
OCaml
5
star
14

reason-on-glitch

ReasonML example on Glitch
OCaml
4
star
15

reyle

β˜€οΈ Managing styles in style
JavaScript
4
star
16

redux-reaction

πŸ’₯ Keeping your Actions and Reducers in the same place
JavaScript
3
star
17

libk

Middleware for Koa@next
JavaScript
2
star
18

standard-ts

TypeScript Standard Style
TypeScript
2
star
19

circleci2-jbuilder

CircleCI 2.0 build image for jbuilder-based OCaml projects
2
star
20

reason-angular

uhhh
JavaScript
1
star
21

quill-authorship

Authorship and change tracking for QuillJS
JavaScript
1
star
22

codacy-coffeescript

β˜• Offers coffeescript support for Codacy
CoffeeScript
1
star
23

cedh.guide

Source code for cedh.guide
TypeScript
1
star
24

AdventOfCode2018

Solutions for the Advent of Code 2018 using Swift πŸ˜„
Swift
1
star
25

angular-template-tag

Use ng-templates inside of <template>
1
star