GitHub repository: rrdelaney/ReasonablyTyped
Description: :diamond_shape_with_a_dot_inside: Converts Flow and TypeScript definitions to Reason interfaces
Topics: bucklescript, bucklescript-bindings, flowtype, reasonml, typescript

v0.13: Reason 3: tag_name: v0.13.0
body: > This whole release was done by @cristianoc in #46!

# Reason 3 Compilation

Output should now be in Reason 3 syntax 😄 Check out how awesome this output is!

```reason
type thing('x) = {. "lst": array('x)};

module Adder = {
  type t('x) = {. "add": [@bs.meth] ('x => 'x)};
  [@bs.new] [@bs.module "generics"] external make : 'x => t('x) = "Adder";
};

type subOpts('m, 'n) = {. "m": 'm, "n": Adder.t('n)};
```

The old syntax won't be supported past this point.

# Optional Object Properties

See more in #46
v0.12: React Components & Imports: tag_name: v0.12
body: # React components are here!

Super short example, but this works now 😄 

```js
import type { Component } from 'react'

declare module 'react-component' {
  declare type props = { input?: string, b?: boolean }
  declare export class ReactComponent extends Component<props> {}
}
```

gets compiled to

```reason
type props = {. "input": Js.Nullable.t(string), "b": Js.Nullable.t(Js.boolean)};

module ReactComponent = {
  [@bs.module "react-component"] external reactcomponent_reactComponent : ReasonReact.reactClass =
    "ReactComponent";
  let make = (~input=?, ~b=?, children) => {
    let props: props = {
      "input": Js.Nullable.from_opt(input),
      "b": Js.Nullable.bind(Js.Nullable.from_opt(b), [@bs] ((x) => Js.Boolean.to_js_boolean(x)))
    };
    ReasonReact.wrapJsForReason(~reactClass=reactcomponent_reactComponent, ~props, children)
  };
};
```

# Imports

Local imports should work exactly how you expect them to 🙂 Absolute imports will get namespaces with the capital module name
v0.11.0: Better Unions: tag_name: v0.11.0
body: # Simpler & Inlined Union Types

It's pretty common in JS to use the following pattern:

```js
declare function add(a: string | number, b: string | number): string
```

Before this release we would generate a helper type for the union, which was eliminated at runtime. Since then  BuckleScript released `@bs.unwrap`, allowing us to produce the following output:

```reason
external add :
  a::[ | `String string | `Number float] [@bs.unwrap] =>
  b::[ | `String string | `Number float] [@bs.unwrap] =>
  string =
  "" [@@bs.module "module"];
```

And the callsite comes pretty naturally! It looks like:

```reason
let result = add (`String "hello") (`Number 3.);
```

Unions of string literals also get processed as `@bs.string` now, making them typesafe (tm):

```js
declare function apply(input: 'add' | 'subtract'): number
```

```reason
external apply :
  input::([`add | `subtract] [@bs.string]) =>
  float =
  "" [@@bs.module "module"];
```

Union declarations will also get inlined too! 

With the input:

```js
declare module 'module' {
  declare type input = number | string
  declare function apply(input: input): number
}
```

You'll get something like:

```reason
external apply :
  input::([`Number float | `String string] [@bs.unwrap]) =>
  float =
  "" [@@bs.module "module"];
```

This should make the API's for a lot more JS libraries easier to use and closer to what JS users would expect.

### Changes
* Better printing of union types
* Objects are now output as open records #29 @bbqbaron 
* Class inheritance is rejected @bbqbaron 
* Date type support #33 @SllyQ 
* CI system
* Test suite against DefinitelyTyped #22 @fstoerkle 
* Pretter pre-commit hook #24 @fstoerkle 


0.10: Generics, modules, and promises: tag_name: v0.10.0
body: This is a pretty big release for ReasonablyTyped, it marks a huge step towards converting many FlowTyped libraries and our first external contributor! Here's what we built in the past few weeks:

# Generics

ReasonablyTyped can now compile classes, interfaces and types that have type parameters!
For example, consider the following class: 

```js
declare class Test<M> {
  constructor<T>(init: T): Test<T>,
  add<N>(value: N): M
}
```

ReasonabyTyped can now turn that into:

```reason
module Test = {
  type t 'm = Js.t {. add: 'n . ('n  => 'm ) [@bs.meth]};
  external make : 't  => t 't  = "Test" [@@bs.new] [@@bs.module "generics"];
};
```

Also note the new code generation for classes! We use the convention on creating a module with a
type named `t` and export a function called `make` to create that type.

# Multiple modules

It can be common to see a Flow definition like:

```js
declare module "multiple-modules" {
  declare export function someTopLevel(): void
}

declare module 'multiple-modules/first' {
  declare export function first(): number 
  declare export function second(): void
}

declare module 'multiple-modules/second' {
  declare export function second(): string 
  declare export function third(): void
}

declare module 'multiple-modules/third' {
  declare export function third(): string 
  declare export function fourth(): void
}

declare module 'multiple-modules/third/inner' {
  declare export function third(): string 
  declare export function fourth(): void
}
```

which declares modules for it's nested files and directories in the same definition,
but still all for the same package. We now take care of these in a smart way and recognize
that they're submodules. The above would produce:

```reason
external someTopLevel : unit => unit = "" [@@bs.module "multiple-modules"];

module First = {
  external first : unit => float = "" [@@bs.module "multiple-modules/first"];
  external second : unit => unit = "" [@@bs.module "multiple-modules/first"];
};

module Second = {
  external second : unit => string = "" [@@bs.module "multiple-modules/second"];
  external third : unit => unit = "" [@@bs.module "multiple-modules/second"];
};

module Third = {
  external third : unit => string = "" [@@bs.module "multiple-modules/third"];
  external fourth : unit => unit = "" [@@bs.module "multiple-modules/third"];
};

module ThirdInner = {
  external third : unit => string = "" [@@bs.module "multiple-modules/third/inner"];
  external fourth : unit => unit = "" [@@bs.module "multiple-modules/third/inner"];
};
```

Shoutout to @bbqbaron for the huge contribution here!

# Changlog
* Support for generic classes, types, and interfaces (#10)
* Support for Promises (#13 @bbqbaron)
* Support for spread arguments (#9 @bbqbarron)
* Render multiple modules declared in the same file (#16 @bbqbaron)
* New renderer for classes
0.9: TypeScript and jbuilder: tag_name: v0.9.0
body: # TypeScript

TypeScript support is here! Pass any file to ReasonablyTyped with the extension `.d.ts` and the TypeScript compilation mode will be used! Note that TypeScript support is still in it's early stages, and might now always produce output. With that said, here's an example!

```typescript
declare module 'numbers' {
  export var xfg: number

  export function add(
    a: number,
    b: number
  ): number
}
```

compiles to

```reason
external xfg : float = "" [@@bs.module "numbers"];

external add : a::float => b::float => float = "" [@@bs.module "numbers"];
```

ReasonablyTyped also supports modules with names determined by their filename, as is often seen in DefinitelyTyped.

# jbuilder

Previously there was a build system in place that depended on Make and rebuild command manually to compile. This system was non-standard and didn't manage libraries or anything like that for you. Now we're using [ReasonNativeProject](https://github.com/reasonml/ReasonNativeProject) as the basis for our build, sprinkled in with some JSOO goodness.
v0.8.0: tag_name: v0.8.0
body: ### Changes

* `Array<$type>` is now processed as an array
* New union type generation
* Call properties on objects (`interface { (x: number): number }`)
* Typeof variable declarations (`declare var exports: typeof MyClass`)

### Internal Changes

* Context now gets passed around in the AST-parser part of the pipeline
* Type detection in code-generation stage

v0.7.6: tag_name: v0.7.6
body: ### Changes
* Top level type aliases are now output into the bindings

For example, this was not processed:

```js
type Options = number | string

declare module 'test' {
  // ...
}
```

but now `Options` is put into the output
v0.7.5: tag_name: v0.7.5
body: ### Changes
* Fix CLI bug
v0.7.4: tag_name: v0.7.4
body: ### Changes
* Fix CLI bug
v0.7.3: tag_name: v0.7.3
body: ### Changes
* Fixes a bug in the CLI
v0.7.2: tag_name: v0.7.2
body: ### Changes
* Better error messages! Errors now contain filenames and locations in the code describing the error

<img width="1018" alt="screen shot 2017-06-04 at 10 28 26 am" src="https://cloud.githubusercontent.com/assets/6325382/26762447/9c4b09e0-4910-11e7-8302-daf6aad83b2a.png">
v0.7.1: tag_name: v0.7.1
body: ### Changes
* Fixes a bug where exported variables would have the first and last character stripped
v0.7.0: tag_name: v0.7.0
body: ### Changes
* Better error messages
* No names on labeled arguments now works
* Support for dictionary-like JS objects
* Support for more types and classes without constructors
* Support regex
* Support for tuple type
* Support for arrays
* Full testing suite against FlowTyped

Currently passes against 49/268 definitions in FlowTyped!

![](https://media.giphy.com/media/l4FGHzb9sBnQmYjyU/giphy.gif)

v0.6.0: tag_name: v0.6.0
body: ### Changes
* Support for optional parameters!
* Support for labeled parameters!
* Some bug fixes where union types weren't being printed

This marks the release where it can compile the `left-pad` definition from `flow-typed` 😄 

v0.5.0: tag_name: v0.5.0
body: ### Changes
* **[Breaking]** No longer export `refmt` and `rawCompile`. The only exported functions from the lib are `compile` and `format`
* Better handling of duplicated union types
v0.4.0: tag_name: v0.4.0
body: ### Changes:
* **[Breaking]** `compile` has a new signature and now formats code. Old exported compile is called `rawCompile`
* `refmt` is exported from the main library
* Removed `--no-fmt` command-line flag
v0.3.0: tag_name: v0.3.0
body: New features:
* Runs all code through `refmt` before outputting. Also checks to make sure output has correct syntax
* Disable output formatting with `--no-fmt`