babel-plugin-type-metadata
v0.4.0
Published
Define Flow type metadata
Downloads
8
Maintainers
Readme
babel-plugin-type-metadata
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"
]
}