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
prop1: number; prop2: Array<User | string>; prop3: Client; prop4: boolean; prop5: Client | User; prop6: ?Array<number>; prop7: Array<User>; prop8: ?a: string b: ?number}; static { return 'cool'; } { return 'yeah'; }} prop1: number; prop2: Array<User | ID>; static { return 'cool'; } { return 'yeah'; } const obj_test = t1 : Test1 t2 : Test2 const test1_str = 't1';const testing_this_string = 'prop1'; console; // numberconsole; // trueconsole; // falseconsole // trueconsole; // undefinedconsole; // falseconsole; // false
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