Flow: gen-flow-files errors when type is referenced from with in it

Created on 15 Nov 2016  路  4Comments  路  Source: facebook/flow

Here is code example:

/* @flow */

export type Widget <message> = {
  init: () => HTMLElement,
  update: (previous:Widget<message>, node:HTMLElement) => ?HTMLElement,
  destroy: (node:HTMLElement) => void
}

Running flow gen-flow-files on that code produces following error:

Unhandled exception: End_of_file
bug gen-flow-files

Most helpful comment

@jeffmo I know it's experimental for now, but I also hope by submitting cases where it brakes I'll get to have it usable sooner ;)

All 4 comments

Oddly using interface instead of type seems to avoid the error

export interface Widget <message> {
  init: () => HTMLElement,
  update: (previous:Widget<message>, node:HTMLElement) => ?HTMLElement,
  destroy: (node:HTMLElement) => void
}

Still output is not quite what I'd expect though, as no Widget export appears:

// @flow

declare class Class1 extends Element<> {

  accessKey: string;
  accessKeyLabel: string;
  className: string;
  contentEditable: string;
  contextMenu: ?HTMLMenuElement;
  dataset: {[key: string]: string};
  dir: "ltr" | "trl" | "auto";
  draggable: boolean;
  dropzone: any;
  hidden: boolean;
  id: string;
  innerHTML: string;
  isContentEditable: boolean;
  itemProp: any;
  itemScope: boolean;
  itemType: any;
  itemValue: Object;
  lang: string;
  offsetHeight: number;
  offsetLeft: number;
  offsetParent: Element;
  offsetTop: number;
  offsetWidth: number;
  onabort: ?Function;
  onblur: ?Function;
  oncancel: ?Function;
  oncanplay: ?Function;
  oncanplaythrough: ?Function;
  onchange: ?Function;
  onclick: ?Function;
  oncuechange: ?Function;
  ondblclick: ?Function;
  ondurationchange: ?Function;
  onemptied: ?Function;
  onended: ?Function;
  onerror: ?Function;
  onfocus: ?Function;
  oninput: ?Function;
  oninvalid: ?Function;
  onkeydown: ?Function;
  onkeypress: ?Function;
  onkeyup: ?Function;
  onload: ?Function;
  onloadeddata: ?Function;
  onloadedmetadata: ?Function;
  onloadstart: ?Function;
  onmousedown: ?Function;
  onmouseenter: ?Function;
  onmouseleave: ?Function;
  onmousemove: ?Function;
  onmouseout: ?Function;
  onmouseover: ?Function;
  onmouseup: ?Function;
  onmousewheel: ?Function;
  onpause: ?Function;
  onplay: ?Function;
  onplaying: ?Function;
  onprogress: ?Function;
  onratechange: ?Function;
  onreadystatechange: ?Function;
  onreset: ?Function;
  onresize: ?Function;
  onscroll: ?Function;
  onseeked: ?Function;
  onseeking: ?Function;
  onselect: ?Function;
  onshow: ?Function;
  onstalled: ?Function;
  onsubmit: ?Function;
  onsuspend: ?Function;
  ontimeupdate: ?Function;
  ontoggle: ?Function;
  onvolumechange: ?Function;
  onwaiting: ?Function;
  properties: any;
  spellcheck: boolean;
  style: CSSStyleDeclaration;
  tabIndex: number;
  title: string;
  translate: boolean;
  blur(): void;
  click(): void;
  focus(): void;
  forceSpellcheck(): void;
  getBoundingClientRect(): ClientRect;
}
declare class Class0 {

  destroy: (node: Class1) => void;
  init: () => Class1;
  update: (previous: Class<Class0<message>>, node: Class1) => ?Class1;
}

declare module.exports: {};

Thanks for the report!

Please note that gen-flow-files is highly experimental and doesn't work in many scenarios right now. We'll be sure to consider this as a test case when we finish it out, though -- so thanks, this is helpful.

@jeffmo I know it's experimental for now, but I also hope by submitting cases where it brakes I'll get to have it usable sooner ;)

gen-flow-files replacement is coming soon

Was this page helpful?
0 / 5 - 0 ratings