babel-plugin-type-metadata

0.4.0 • Public • Published

babel-plugin-type-metadata Build Status Coverage Status

This plugin generates code to identify Flow types at runtime via metadata.

Usage

If you run the plugin on the following input

/* @flow */
 
class MyClass {
  stringMethod(): string {
    return 'string';
  }
}

it will create add the following metadata:

Reflect.defineMetadata('typeof', {
  kind: 'method',
  returns: {
    type: String
  },
  parameters: []
}, MyClass, 'stringMethod');

Important: Since the reflection API is still just a proposal at this time, you'll need a polyfill like core-js.

Get Started

Install the plugin:

npm install babel-plugin-type-metadata --save-dev

And add the additional step to your .babelrc:

{
  "plugins": [
    "babel-plugin-syntax-flow",
    "babel-plugin-type-metadata"
  ]
}

Package Sidebar

Install

npm i babel-plugin-type-metadata

Weekly Downloads

0

Version

0.4.0

License

MIT

Last publish

Collaborators

  • 101loops