New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-flow-type-getter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-flow-type-getter

Access flow types from uninstantiated classes.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by850%
Maintainers
1
Weekly downloads
 
Created
Source

Access your Flow types from classes before you instantiate objects.


To use :

npm install --save-dev babel-plugin-flow-type-getter babel-plugin-transform-flow-strip-types

.babelrc

{
  "plugins": ["flow-type-getter", "transform-flow-strip-types"]
}

Example

class Test1 {
  prop1: number;
  prop2: Test2;
  prop3: string | Test1;
}
class Test2 {
  prop1: string;
  prop2: Array<number>
  prop3: ?Array<Test1 | string>;
}

typeof Test1.prop1; // 'number'
typeof Test1.prop3; // 'string | Test1'
typeof Test1.prop2 == 'Test2'; // true
typeof Test2.prop1 == 'Test1'; // false
Array.isArray(Test2.prop3); // true

Run the example

-Navigate to the example directory of the project
-Open the file index.js in a text editor (only do this if you want to expriment)
-Enter the command npm run build to start the babel --watch process (keep this shell open)
-In a new shell, enter the command npm start to see the values logged out in example/index.js

Keywords

FAQs

Package last updated on 28 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc