Skip to content

About

Converts WebIDL to Flow Library Definitions

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Web IDL to Flow

Convert Web IDL definitions to Flow library definitions.

Many Web standards are formalized in Web IDL, such as DOM, HTML, SVG, and so on. This tool converts Web IDL into types for the Flow type checker, which can be used for library and environment definitions (see also flow-typed).

For exmaple, given this Web IDL snippet:

interface SVGGraphicsElement : SVGElement {
  [SameObject] readonly attribute SVGAnimatedTransformList transform;

  DOMRect getBBox(optional SVGBoundingBoxOptions options);
  DOMMatrix? getCTM();
  DOMMatrix? getScreenCTM();
};

SVGGraphicsElement includes SVGTests;

This tool will produce the following definition:

declare class SVGGraphicsElement extends SVGElement mixins SVGTests {
  +transform: SVGAnimatedTransformList;

  getBBox(options?: SVGBoundingBoxOptions): DOMRect;
  getCTM(): DOMMatrix | null;
  getScreenCTM(): DOMMatrix | null;
}

Usage

First, install:

yarn install
yarn build

Then, pipe a list of Web IDL files to the generate command:

find path/to/input/ -type f | node dist/index.js generate path/to/output/

This repository comes packaged with several Web IDL files under /idl. Those can be converted to Flow definitions with this shorthand:

yarn go

About

Converts WebIDL to Flow Library Definitions

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages