rrdelaney / ReasonablyTyped

:diamond_shape_with_a_dot_inside: Converts Flow and TypeScript definitions to Reason interfaces
https://rrdelaney.github.io/ReasonablyTyped/
MIT License
518 stars 24 forks source link

featured flow example in readme does not work #55

Closed zploskey closed 6 years ago

zploskey commented 6 years ago

This example in the README does not work.

// 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;
  }
}

Running retyped on it produces a file t.re containing only

y

I ran this because I was trying to update the example to Reason 3 syntax, but this will need to be fixed first or changed to something that will compile.

rrdelaney commented 6 years ago

Seems to work for me on master:

ryan@ryan-desktop ~/d/ReasonablyTyped> cat _test.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;
  }
}
ryan@ryan-desktop ~/d/ReasonablyTyped> node lib/cli.js ./_test.js --debug
=== Imports ===

=== Types ===

typeof State = { id: number, storeName: string }
typeof Store = Class

=== Flow Definition ===
declare module 'classes' {
  declare type State = { id: number, storeName: string }
  declare class Store { constructor: (initialState: State): Store; state: State; update: (nextState: State): void }
}

=== Bucklescript Definition ===
/* 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";
};

Compiled 0 files
zploskey commented 6 years ago

Seems to have been fixed. Sweet!