├── src ├── typing │ └── deps_js.ml ├── parser │ ├── tools │ │ ├── .gitignore │ │ └── Makefile │ ├── .gitignore │ ├── .npmignore │ └── test │ │ └── run_all.sh ├── dts │ └── tests │ │ ├── numbered_keys │ │ ├── .flowconfig │ │ ├── numbered_keys.js │ │ ├── declarations │ │ │ ├── numbered_keys.d.ts │ │ │ └── numbered_keys.js.exp │ │ └── numbered_keys.exp │ │ ├── union │ │ ├── declarations │ │ │ ├── union.d.ts │ │ │ └── union.js.exp │ │ ├── union.js │ │ ├── .flowconfig │ │ └── union.exp │ │ ├── enums │ │ ├── declarations │ │ │ ├── enums.d.ts │ │ │ └── enums.js.exp │ │ ├── .flowconfig │ │ ├── enums.exp │ │ └── enums.js │ │ ├── functions │ │ ├── functions.js │ │ ├── .flowconfig │ │ └── declarations │ │ │ ├── functions.d.ts │ │ │ └── functions.js.exp │ │ ├── classes │ │ ├── .flowconfig │ │ ├── classes.js │ │ ├── declarations │ │ │ ├── classes.js.exp │ │ │ └── classes.d.ts │ │ └── classes.exp │ │ ├── modules │ │ ├── .flowconfig │ │ ├── modules.js │ │ └── declarations │ │ │ ├── modules.d.ts │ │ │ └── modules.js.exp │ │ ├── modules2 │ │ ├── .flowconfig │ │ ├── modules2.js │ │ ├── declarations │ │ │ ├── modules2.d.ts │ │ │ └── modules2.js.exp │ │ └── modules2.exp │ │ ├── type_alias │ │ ├── .flowconfig │ │ ├── type_alias.js │ │ ├── declarations │ │ │ ├── type_alias.d.ts │ │ │ └── type_alias.js.exp │ │ └── type_alias.exp │ │ ├── export_modules │ │ ├── .flowconfig │ │ ├── export_modules.js │ │ ├── export_modules.exp │ │ └── declarations │ │ │ └── export_modules.d.ts │ │ ├── import_commonjs │ │ ├── .flowconfig │ │ ├── import_commonjs.js │ │ └── import_commonjs.exp │ │ ├── interface_var │ │ ├── .flowconfig │ │ ├── interface_var.js │ │ ├── declarations │ │ │ ├── interface_var.js.exp │ │ │ └── interface_var.d.ts │ │ └── interface_var.exp │ │ ├── nested_modules │ │ ├── .flowconfig │ │ └── nested_modules.js │ │ └── var_interface │ │ ├── .flowconfig │ │ ├── var_interface.js │ │ ├── declarations │ │ ├── var_interface.js.exp │ │ └── var_interface.d.ts │ │ └── var_interface.exp ├── stubs │ └── haste_module_preprocessor.mli ├── common │ ├── FlowJSON.mli │ └── span.mli └── embedded │ └── flowlib.mli ├── tests ├── react │ ├── .flowconfig │ ├── import_react.js │ ├── proptype_oneOf.js │ ├── jsx_spread.js │ ├── ArityError.react.js │ ├── proptype_object.js │ └── proptype_func.js ├── rec │ └── .flowconfig ├── shape │ ├── .flowconfig │ ├── shape.exp │ └── test.js ├── throw │ ├── .flowconfig │ ├── throw.exp │ └── test.js ├── try │ ├── .flowconfig │ └── try.exp ├── unary │ └── .flowconfig ├── while │ ├── .flowconfig │ ├── while.exp │ ├── test.js │ └── abnormal.js ├── .gitignore ├── auxiliary │ ├── .flowconfig │ ├── client.js │ ├── lib │ │ └── lib.js │ └── real_node_modules │ │ └── symlink_lib_outside_root │ │ ├── index.js │ │ └── package.json ├── binding │ └── .flowconfig ├── class_type │ ├── .flowconfig │ ├── class_type.exp │ └── test.js ├── covariance │ ├── .flowconfig │ └── covariance.exp ├── deps │ ├── F.js │ ├── H.js │ ├── A.js │ ├── B.js │ ├── D.js │ ├── E.js │ ├── G.js │ ├── I.js │ ├── deps.exp │ ├── .flowconfig │ └── C.js ├── dictionary │ ├── .flowconfig │ ├── test_client.js │ └── test.js ├── dump-types │ ├── .flowconfig │ ├── .testconfig │ ├── import.js │ └── test.js ├── extensions │ ├── .flowconfig │ ├── bar.jsx │ ├── foo.js │ └── extensions.exp ├── issues-11 │ ├── .flowconfig │ ├── export.js │ ├── import.js │ └── issues-11.exp ├── mixins │ ├── .flowconfig │ ├── Bar.js │ ├── test.js │ └── mixins.exp ├── node_haste │ ├── ws │ │ ├── index.js │ │ └── test │ │ │ └── client.js │ ├── external │ │ └── _d3 │ │ │ ├── min.js │ │ │ └── package.json │ ├── md5.js │ ├── node_modules │ │ └── qux │ │ │ ├── corge │ │ │ ├── lib │ │ │ │ └── index.js │ │ │ └── package.json │ │ │ └── docblock.js │ ├── client.js │ ├── .flowconfig │ ├── node_haste.exp │ └── foo │ │ └── bar │ │ └── client.js ├── node_tests │ ├── .flowconfig │ ├── jsx │ │ ├── .flowconfig │ │ ├── bar.jsx │ │ └── foo.jsx │ ├── basic │ │ ├── .flowconfig │ │ ├── bar.js │ │ └── foo.js │ ├── jsx_file │ │ ├── .flowconfig │ │ ├── bar.jsx │ │ └── foo.jsx │ ├── stream │ │ └── .flowconfig │ ├── basic_file │ │ ├── .flowconfig │ │ ├── bar.js │ │ └── foo.js │ ├── basic_package │ │ ├── .flowconfig │ │ ├── bar_lib │ │ │ ├── bar.js │ │ │ └── package.json │ │ └── foo.js │ ├── child_process │ │ ├── .flowconfig │ │ └── exec.js │ ├── package_file │ │ ├── .flowconfig │ │ ├── bar_lib │ │ │ ├── bar.js │ │ │ └── package.json │ │ ├── bar_lib.js │ │ └── foo.js │ ├── path_package │ │ ├── .flowconfig │ │ ├── node_modules │ │ │ └── bar_lib │ │ │ │ └── src │ │ │ │ └── lib │ │ │ │ ├── bar.js │ │ │ │ └── package.json │ │ └── foo.js │ ├── basic_node_modules │ │ ├── .flowconfig │ │ ├── node_modules │ │ │ └── bar.js │ │ └── foo.js │ ├── path_node_modules │ │ ├── .flowconfig │ │ ├── node_modules │ │ │ └── bar_lib │ │ │ │ └── src │ │ │ │ └── lib │ │ │ │ └── bar.js │ │ └── foo.js │ ├── invalid_package_file │ │ ├── .flowconfig │ │ └── package.json │ ├── package_file_node_modules │ │ ├── .flowconfig │ │ ├── node_modules │ │ │ └── bar_lib.js │ │ └── foo │ │ │ ├── node_modules │ │ │ └── bar_lib │ │ │ │ ├── bar.js │ │ │ │ └── package.json │ │ │ └── foo.js │ ├── basic_node_modules_with_path │ │ ├── node_modules │ │ │ └── bar_lib │ │ │ │ └── bar.js │ │ └── foo.js │ ├── path_node_modules_with_short_main │ │ ├── node_modules │ │ │ └── bar_lib │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ └── foo.js │ ├── path_node_modules_with_symlinks │ │ ├── node_modules │ │ │ ├── symlink_lib │ │ │ └── symlink_lib_outside_root │ │ ├── real_node_modules │ │ │ └── symlink_lib │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ └── foo.js │ ├── path_node_modules_without_main │ │ ├── foo.js │ │ └── node_modules │ │ │ └── bar_lib │ │ │ ├── index.js │ │ │ └── package.json │ ├── node_tests.exp │ └── assert │ │ └── assert.js ├── parse │ ├── fail.js │ ├── fail-flow.js │ ├── fail-flow-2.js │ ├── .flowconfig │ ├── no_parse_error.js │ └── parse.exp ├── record │ └── .flowconfig ├── return_new │ ├── .flowconfig │ ├── test2.js │ └── test.js ├── singleton │ ├── .flowconfig │ └── number.js ├── spread │ ├── .flowconfig │ ├── test4.js │ ├── test2.js │ └── test3.js ├── bounded_poly │ ├── .flowconfig │ └── scope.js ├── builtin_uses │ ├── .flowconfig │ ├── test2.js │ ├── test.js │ └── builtin_uses.exp ├── class_statics │ └── .flowconfig ├── class_subtyping │ ├── .flowconfig │ ├── test.js │ ├── test2.js │ ├── test4.js │ └── test3.js ├── declare_fun │ ├── .flowconfig │ ├── declare_fun.exp │ └── test.js ├── export_type │ ├── .flowconfig │ ├── cjs_with_types.js │ └── types_only2.js ├── geolocation │ ├── .flowconfig │ └── geolocation.exp ├── object_annot │ ├── .flowconfig │ ├── object_annot.exp │ └── test.js ├── optional_props │ ├── .flowconfig │ └── test.js ├── sealed_objects │ └── .flowconfig ├── strict_requires │ ├── .flowconfig │ ├── A.js │ ├── B.js │ ├── C.js │ ├── D.js │ └── strict_requires.exp ├── type-at-pos │ ├── .flowconfig │ ├── .testconfig │ ├── import.js │ ├── test.js │ └── type-at-pos.exp ├── unreachable │ ├── .flowconfig │ └── unreachable.exp ├── constructor_annots │ └── .flowconfig ├── es6modules │ ├── C.js │ ├── SideEffects.js │ ├── B.js │ ├── ProvidesModuleD.js │ ├── ES6_DefaultAndNamed.js │ ├── .flowconfig │ ├── ES6_ExportAllFrom_Source1.js │ ├── ES6_ExportAllFrom_Source2.js │ ├── ProvidesModuleCJSDefault.js │ ├── ES6_ExportFrom_Source1.js │ ├── ES6_ExportFrom_Source2.js │ ├── ES6_Default_AnonFunction1.js │ ├── ES6_Default_AnonFunction2.js │ ├── ES6_Default_AnonClass1.js │ ├── ES6_Default_AnonClass2.js │ ├── ES6_Default_NamedFunction1.js │ ├── ES6_Default_NamedFunction2.js │ ├── ES6_ExportAllFrom_Intermediary1.js │ ├── ES6_ExportAllFrom_Intermediary2.js │ ├── ProvidesModuleES6Default.js │ ├── ES6_Default_NamedClass2.js │ ├── ES6_ExportFrom_Intermediary1.js │ ├── ES6_ExportFrom_Intermediary2.js │ ├── ProvidesModuleA.js │ ├── CommonJS_Named.js │ ├── CommonJS_Clobbering_Lit.js │ └── ES6_Default_NamedClass1.js ├── immutable_methods │ ├── .flowconfig │ ├── immutable_methods.exp │ └── test.js ├── liberr │ ├── .testconfig │ ├── libs │ │ ├── type_error.js │ │ └── parse_error.js │ ├── a.js │ ├── .flowconfig │ └── liberr.exp ├── method_properties │ ├── .flowconfig │ ├── test.js │ └── method_properties.exp ├── parse_error_node │ ├── .flowconfig │ ├── .testconfig │ ├── parse_error_node.exp │ ├── Client.js │ ├── Unimported.js │ └── Imported.js ├── require │ ├── C.js │ ├── B.js │ ├── ProvidesModuleD.js │ ├── .flowconfig │ ├── ProvidesModuleA.js │ └── E.js ├── x │ ├── x.exp │ └── .flowconfig ├── for │ ├── for.exp │ └── .flowconfig ├── init │ ├── init.exp │ ├── .flowconfig │ └── nullable-init.js ├── path │ ├── path.exp │ ├── .flowconfig │ └── while.js ├── export_default │ ├── .flowconfig │ ├── P.js │ ├── test.js │ └── lib │ │ └── lib.js ├── funrec │ ├── funrec.exp │ ├── .flowconfig │ └── funrec.js ├── parse_error_haste │ ├── .testconfig │ ├── .flowconfig │ ├── Unimported.js │ ├── NoProvides.js │ ├── parse_error_haste.exp │ ├── Provides.js │ └── Client.js ├── static_overload │ ├── .flowconfig │ ├── static_overload.exp │ ├── test.js │ └── lib │ │ └── lib.js ├── symbol │ ├── symbol.exp │ ├── .flowconfig │ └── symbol.js ├── window │ ├── window.exp │ ├── .flowconfig │ ├── window2.js │ └── window1.js ├── abnormal │ ├── abnormal.exp │ ├── .flowconfig │ ├── return.js │ └── break-continue.js ├── declare_type │ ├── .flowconfig │ ├── lib │ │ └── DeclareModule_TypeAlias.js │ └── declare_type.exp ├── graphql │ ├── graphql.exp │ └── .flowconfig ├── librec │ ├── libtest.js │ ├── lib │ │ ├── A │ │ │ └── libA.js │ │ └── B │ │ │ └── libB.js │ ├── .flowconfig │ └── librec.exp ├── replace │ ├── replace.exp │ ├── .flowconfig │ └── test.js ├── unicode │ ├── unicode.exp │ └── .flowconfig ├── incremental │ ├── incremental.exp │ ├── a.js │ ├── dup_a.js │ ├── .flowconfig │ └── b.js ├── libconfig │ ├── libtest.js │ ├── libA.js │ ├── libB.js │ ├── .flowconfig │ └── libconfig.exp ├── refinements │ ├── node1.js │ ├── .flowconfig │ ├── lib.js │ ├── null.js │ ├── ast_node.js │ └── union.js ├── suppress │ ├── B.js │ ├── lib.js │ ├── suppress.exp │ └── .flowconfig ├── .flowconfig ├── lib_interfaces │ ├── lib_interfaces.exp │ ├── .flowconfig │ └── declarations │ │ └── underscore.js ├── objects │ └── .flowconfig ├── annot │ ├── .flowconfig │ ├── other.js │ ├── test.js │ └── issue-530.js ├── arith │ ├── .flowconfig │ └── mult.js ├── arrays │ ├── .flowconfig │ └── arrays.exp ├── arrows │ ├── .flowconfig │ ├── advanced_arrows.js │ └── arrows.js ├── async │ ├── .flowconfig │ ├── async_promise.js │ ├── await_not_in_async.js │ ├── await_not_in_async2.js │ └── await_not_in_async3.js ├── autocomplete │ ├── autocomplete.exp │ ├── .flowconfig │ ├── .testconfig │ └── foo.js ├── break │ └── .flowconfig ├── classes │ ├── .flowconfig │ ├── D.js │ ├── A.js │ ├── B.js │ ├── loc.js │ └── C.js ├── closure │ ├── .flowconfig │ └── closure.exp ├── conditional │ ├── .flowconfig │ └── conditional.exp ├── cycle │ ├── .flowconfig │ ├── A.js │ ├── B.js │ └── cycle.exp ├── date │ └── .flowconfig ├── demo │ ├── 1 │ │ ├── .flowconfig │ │ └── f.js │ ├── 2 │ │ ├── .flowconfig │ │ ├── B.js │ │ └── A.js │ └── .flowconfig ├── encaps │ └── .flowconfig ├── equals │ ├── .flowconfig │ ├── equals.js │ └── equals.exp ├── get-def │ ├── .flowconfig │ ├── .testconfig │ ├── get-def.exp │ ├── library.js │ └── example.js ├── indexer │ └── .flowconfig ├── iter │ └── .flowconfig ├── lib │ ├── .flowconfig │ └── libtest.js ├── literal │ ├── .flowconfig │ └── enum.js ├── locals │ ├── .flowconfig │ └── locals.js ├── logical │ └── .flowconfig ├── loners │ ├── .flowconfig │ ├── loners.exp │ └── loners.js ├── misc │ ├── .flowconfig │ ├── G.js │ ├── F.js │ ├── E.js │ ├── C.js │ ├── D.js │ ├── B.js │ └── A.js ├── modules │ ├── .flowconfig │ ├── cli2.js │ ├── cli.js │ ├── lib.js │ └── modules.exp ├── poly │ ├── .flowconfig │ ├── poly.js │ └── annot.js ├── refi │ ├── .flowconfig │ └── switch.js ├── regexp │ ├── .flowconfig │ ├── regexp.js │ └── regexp.exp ├── return │ ├── .flowconfig │ └── return.exp ├── seal │ ├── .flowconfig │ ├── imp.js │ ├── seal.exp │ └── obj_annot.js ├── sealed │ ├── .flowconfig │ ├── function.js │ ├── sealed.js │ └── proto.js ├── statics │ ├── .flowconfig │ ├── funstatics.js │ └── class_statics.js ├── strict │ ├── .flowconfig │ ├── obj.js │ ├── annot.js │ └── fun.js ├── suggest │ ├── .flowconfig │ ├── lib.js │ └── suggest.js ├── super │ ├── .flowconfig │ ├── import.js │ ├── test.js │ └── super.js ├── switch │ ├── .flowconfig │ └── switch.exp ├── this │ └── .flowconfig ├── tuples │ ├── .flowconfig │ ├── tuples.exp │ └── tuples.js ├── union │ ├── .flowconfig │ ├── issue-323-lib.js │ ├── test-lib.js │ ├── issue-323.js │ ├── fields.js │ ├── issue-324.js │ ├── issue-326.js │ ├── fields2.js │ ├── issue-256.js │ ├── issue-198.js │ ├── issue-325.js │ └── issue-17.js ├── value │ ├── .flowconfig │ ├── value.js │ └── value.exp ├── yield │ ├── .flowconfig │ ├── yield_arrow_error2.js │ ├── yield_arrow_error.js │ └── yield.exp ├── arraylib │ └── .flowconfig ├── builtins │ ├── .flowconfig │ └── genericfoo.js ├── callable │ ├── .flowconfig │ └── primitives.js ├── commonjs │ ├── .flowconfig │ ├── Rel.js │ ├── Abs.js │ └── commonjs.exp ├── constructor ├── docblock │ ├── .flowconfig │ └── docblock.exp ├── enumerror │ ├── .flowconfig │ └── enumerror.exp ├── fixpoint │ └── .flowconfig ├── generics │ └── .flowconfig ├── instanceof │ └── .flowconfig ├── interface │ ├── .flowconfig │ ├── interface.js │ └── interface.exp ├── intersection │ ├── .flowconfig │ ├── intersection.js │ ├── intersection.exp │ └── test.js ├── keyvalue │ ├── .flowconfig │ ├── keyvalue.js │ └── keyvalue.exp ├── more_annot │ ├── .flowconfig │ ├── client_object.js │ ├── super.js │ ├── more_annot.exp │ ├── proto.js │ └── object.js ├── more_classes │ ├── .flowconfig │ ├── Qux.js │ └── Bar.js ├── more_path │ ├── .flowconfig │ ├── FlowSA.js │ └── test.js ├── more_react │ ├── .flowconfig │ ├── JSX.js │ └── API.react.js ├── more_statics │ ├── .flowconfig │ ├── class_static.js │ └── more_statics.exp ├── namespace │ ├── .flowconfig │ └── client.js ├── nullable │ ├── .flowconfig │ └── simple_nullable.js ├── object_api │ ├── .flowconfig │ ├── a.js │ ├── c.js │ ├── object_keys.js │ ├── b.js │ └── object_assign.js ├── optional │ ├── .flowconfig │ ├── client_optional.js │ ├── maybe.js │ ├── undefined2.js │ ├── undefined.js │ ├── optional_param3.js │ ├── optional_param2.js │ └── optional.js ├── plsummit │ ├── .flowconfig │ ├── import_class.js │ ├── generics.js │ ├── arrays.js │ ├── export_class.js │ ├── locals.js │ └── objects.js ├── promises │ └── .flowconfig ├── qualified │ ├── .flowconfig │ ├── qualified.js │ └── qualified.exp ├── reflection │ ├── .flowconfig │ ├── type.js │ └── reflection.exp ├── type_param_variance │ ├── type_param_variance.exp │ └── .flowconfig ├── typecast │ ├── .flowconfig │ └── typecast.exp ├── undefined │ ├── .flowconfig │ ├── undefined2.js │ ├── undefined.exp │ └── undefined.js ├── weakmode │ ├── .flowconfig │ ├── weakmode.exp │ ├── should_fail_without_weak.js │ └── should_pass_with_weak.js ├── ast_tokens │ ├── .testconfig │ ├── .flowconfig │ └── foo.js ├── destructuring │ ├── .flowconfig │ └── destructuring_param.js ├── error_messages │ ├── .flowconfig │ ├── errors.js │ └── error_messages.exp ├── more_generics │ └── .flowconfig ├── number_constants │ └── .flowconfig ├── object_freeze │ └── .flowconfig ├── simple_arrays │ ├── .flowconfig │ ├── simple_arrays.exp │ └── array.js ├── type_param_variance2 │ ├── type_param_variance2.exp │ └── .flowconfig ├── missing_annotation │ └── .flowconfig ├── config_munging_underscores │ ├── config_munging_underscores.exp │ └── .flowconfig ├── import_type │ ├── ExportsANumber.js │ ├── .flowconfig │ ├── issue-359.js │ ├── ExportNamed_Class.js │ ├── ExportDefault_Class.js │ ├── ExportNamed_Alias.js │ └── ExportCJSDefault_Class.js ├── import_typeof │ ├── ExportCJSNamed_Number.js │ ├── ExportDefault_Number.js │ ├── ExportNamed_Number.js │ ├── ExportCJSDefault_Number.js │ ├── .flowconfig │ ├── ExportCJSNamed_Class.js │ ├── ExportNamed_Class.js │ ├── ExportDefault_Class.js │ ├── ExportCJSDefault_Class.js │ └── ExportNamed_Alias.js ├── overload │ ├── .flowconfig │ ├── union.js │ ├── test.js │ ├── lib │ │ └── lib.js │ └── test2.js ├── declare_class │ ├── .flowconfig │ ├── declare_class.js │ └── lib │ │ └── test.js ├── forof │ └── .flowconfig ├── function │ ├── .flowconfig │ └── function.exp ├── include │ └── .flowconfig ├── iterable │ ├── .flowconfig │ ├── string.js │ ├── iter.js │ ├── array.js │ └── set.js ├── module_redirect │ ├── A.js │ ├── B.js │ ├── C.js │ ├── .flowconfig │ ├── D.js │ └── module_redirect.exp ├── new_react │ ├── .flowconfig │ ├── Mixin.js │ ├── state2.js │ └── state3.js ├── private │ ├── .flowconfig │ ├── private.exp │ └── private.js ├── traces │ └── .flowconfig ├── typeof │ └── .flowconfig ├── object_assign │ ├── .flowconfig │ └── non_objects.js ├── suppress_traces │ ├── .testconfig │ └── .flowconfig ├── autocomplete_json │ ├── .flowconfig │ ├── .testconfig │ ├── foo.js │ └── autocomplete_json.exp ├── call_properties │ ├── .flowconfig │ └── E.js ├── type_only_vars │ ├── .flowconfig │ ├── A.js │ ├── type_alias.js │ └── import_type.js ├── structural_subtyping │ ├── .flowconfig │ └── builtin.js ├── class_property_initializers │ ├── .flowconfig │ ├── class_property_initializers.js │ └── class_property_initializers.exp ├── config_munging_underscores2 │ └── .flowconfig ├── getters_and_setters_disabled │ ├── .flowconfig │ ├── getters_and_setters.js │ └── getters_and_setters_disabled.exp ├── suppress_bad │ ├── suppress_bad.exp │ └── .flowconfig ├── config_module_name_rewrite_node │ ├── Exists.js │ └── node_modules │ │ └── Exists │ │ └── index.js ├── object_is │ ├── .flowconfig │ └── object_is.exp ├── any │ ├── .flowconfig │ └── any.js ├── requireLazy │ ├── .flowconfig │ ├── A.js │ └── B.js ├── ignore_package │ ├── ignore_package.exp │ ├── .flowconfig │ ├── node_modules │ │ └── underscore │ │ │ └── package.json │ └── foo.js ├── version │ ├── .flowconfig │ └── version.exp ├── getters_and_setters_enabled │ ├── .flowconfig │ └── react.js └── config_module_name_rewrite_haste │ ├── Exists.js │ └── config_module_name_rewrite_haste.exp ├── auxiliary_tests ├── .flowconfig ├── basic_test.js ├── node_modules │ ├── Bar.js │ └── Foo_.js ├── type_test.js └── module_test.js ├── examples ├── 03_Null │ ├── .flowconfig │ ├── nulls.js │ └── answer │ │ └── nulls.js ├── 04_Arrays │ ├── .flowconfig │ ├── arrays.js │ └── answer │ │ └── arrays.js ├── flux-chat │ └── .flowconfig ├── 01_HelloWorld │ ├── .flowconfig │ ├── hello.js │ └── answer │ │ └── hello.js ├── 05_DynamicCode │ ├── .flowconfig │ ├── dynamic.js │ └── answer │ │ └── dynamic.js └── 02_TypeAnnotations │ ├── .flowconfig │ ├── type_annotations.js │ └── answer │ └── type_annotations.js ├── .flowconfig ├── hack ├── .gitignore ├── stubs │ ├── filesToIgnore.ml │ ├── debug.ml │ ├── linting_service.ml │ ├── prolog.ml │ ├── prologMain.ml │ └── formatEventLogger.ml ├── utils │ ├── .gitignore │ └── core.ml ├── js │ ├── ocaml_sys.js │ └── hhi.ml ├── third-party │ ├── core │ │ ├── VERSION │ │ ├── poly.ml │ │ ├── polymorphic_compare.ml │ │ └── core_printf.ml │ └── inotify │ │ ├── origin.txt │ │ └── META ├── server │ └── serverMain.mli └── typing │ └── typing_alias.mli ├── auxiliary └── lib │ └── auxiliary.js ├── .gitignore ├── CONTRIBUTING.md └── _tags /src/typing/deps_js.ml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/react/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/rec/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/shape/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/throw/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/try/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unary/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/while/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /auxiliary_tests/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/03_Null/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | -------------------------------------------------------------------------------- /tests/auxiliary/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/binding/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/class_type/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/covariance/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/deps/F.js: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /tests/deps/H.js: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /tests/dictionary/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dump-types/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/extensions/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/issues-11/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/mixins/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_haste/ws/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/parse/fail.js: -------------------------------------------------------------------------------- 1 | . 2 | -------------------------------------------------------------------------------- /tests/record/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/return_new/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/singleton/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/spread/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/04_Arrays/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/flux-chat/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/bounded_poly/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/builtin_uses/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/class_statics/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/class_subtyping/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/declare_fun/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/export_type/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/geolocation/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/jsx/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/object_annot/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/optional_props/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/sealed_objects/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/strict_requires/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/type-at-pos/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unreachable/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /auxiliary_tests/basic_test.js: -------------------------------------------------------------------------------- 1 | XXX 2 | -------------------------------------------------------------------------------- /examples/01_HelloWorld/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/05_DynamicCode/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/constructor_annots/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/deps/A.js: -------------------------------------------------------------------------------- 1 | require('./C'); 2 | -------------------------------------------------------------------------------- /tests/deps/B.js: -------------------------------------------------------------------------------- 1 | require('./C'); 2 | -------------------------------------------------------------------------------- /tests/deps/D.js: -------------------------------------------------------------------------------- 1 | require('./I'); 2 | -------------------------------------------------------------------------------- /tests/deps/E.js: -------------------------------------------------------------------------------- 1 | require('./I'); 2 | -------------------------------------------------------------------------------- /tests/deps/G.js: -------------------------------------------------------------------------------- 1 | require('./H'); 2 | -------------------------------------------------------------------------------- /tests/deps/I.js: -------------------------------------------------------------------------------- 1 | require('./A'); 2 | -------------------------------------------------------------------------------- /tests/es6modules/C.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | -------------------------------------------------------------------------------- /tests/immutable_methods/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/liberr/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: status -------------------------------------------------------------------------------- /tests/method_properties/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_haste/external/_d3/min.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/basic/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/jsx_file/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/stream/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/parse_error_node/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/require/C.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | -------------------------------------------------------------------------------- /tests/x/x.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | -------------------------------------------------------------------------------- /examples/02_TypeAnnotations/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/deps/deps.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/for/for.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/init/init.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/node_tests/basic_file/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/basic_package/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/child_process/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/package_file/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/path_package/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/path/path.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /hack/.gitignore: -------------------------------------------------------------------------------- 1 | *.bc 2 | *.opt 3 | !Makefile 4 | -------------------------------------------------------------------------------- /tests/auxiliary/client.js: -------------------------------------------------------------------------------- 1 | var y:number = x; 2 | -------------------------------------------------------------------------------- /tests/es6modules/SideEffects.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | -------------------------------------------------------------------------------- /tests/export_default/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | lib -------------------------------------------------------------------------------- /tests/funrec/funrec.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/node_tests/basic_node_modules/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/parse_error_haste/.testconfig: -------------------------------------------------------------------------------- 1 | all: false -------------------------------------------------------------------------------- /tests/parse_error_node/.testconfig: -------------------------------------------------------------------------------- 1 | all: false -------------------------------------------------------------------------------- /tests/shape/shape.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/static_overload/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | lib -------------------------------------------------------------------------------- /tests/symbol/symbol.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/while/while.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/window/window.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /src/parser/tools/.gitignore: -------------------------------------------------------------------------------- 1 | native_test_files 2 | -------------------------------------------------------------------------------- /tests/abnormal/abnormal.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/auxiliary/lib/lib.js: -------------------------------------------------------------------------------- 1 | declare var x: string; 2 | -------------------------------------------------------------------------------- /tests/declare_type/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | lib 3 | -------------------------------------------------------------------------------- /tests/graphql/graphql.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/librec/libtest.js: -------------------------------------------------------------------------------- 1 | foo(123); 2 | bar(123); 3 | -------------------------------------------------------------------------------- /tests/node_haste/md5.js: -------------------------------------------------------------------------------- 1 | /* @providesModule md5 */ 2 | -------------------------------------------------------------------------------- /tests/node_haste/node_modules/qux/corge/lib/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/invalid_package_file/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/node_tests/invalid_package_file/package.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/parse/fail-flow.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | . 4 | -------------------------------------------------------------------------------- /tests/replace/replace.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/unicode/unicode.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/class_type/class_type.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/geolocation/geolocation.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/incremental/incremental.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/libconfig/libtest.js: -------------------------------------------------------------------------------- 1 | foo(123); 2 | bar(123); 3 | -------------------------------------------------------------------------------- /tests/node_haste/client.js: -------------------------------------------------------------------------------- 1 | var md5 = require('./md5'); 2 | -------------------------------------------------------------------------------- /tests/node_tests/basic/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/jsx/bar.jsx: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/package_file_node_modules/.flowconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/refinements/node1.js: -------------------------------------------------------------------------------- 1 | module.exports = 'Node1'; 2 | -------------------------------------------------------------------------------- /tests/suppress/B.js: -------------------------------------------------------------------------------- 1 | var test1: string = library_num; 2 | -------------------------------------------------------------------------------- /hack/stubs/filesToIgnore.ml: -------------------------------------------------------------------------------- 1 | let should_ignore _ = false 2 | -------------------------------------------------------------------------------- /tests/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | traces=2 -------------------------------------------------------------------------------- /tests/export_default/P.js: -------------------------------------------------------------------------------- 1 | module.exports = require('M'); 2 | -------------------------------------------------------------------------------- /tests/incremental/a.js: -------------------------------------------------------------------------------- 1 | /* @providesModule IncrModuleA */ 2 | -------------------------------------------------------------------------------- /tests/lib_interfaces/lib_interfaces.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/node_haste/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste -------------------------------------------------------------------------------- /tests/node_haste/external/_d3/package.json: -------------------------------------------------------------------------------- 1 | { "name": "d3" } 2 | -------------------------------------------------------------------------------- /tests/node_haste/ws/test/client.js: -------------------------------------------------------------------------------- 1 | var ws = require('../'); 2 | -------------------------------------------------------------------------------- /tests/node_tests/basic_file/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/jsx_file/bar.jsx: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/object_annot/object_annot.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/objects/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | -------------------------------------------------------------------------------- /tests/parse/fail-flow-2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow */ 3 | 4 | . 5 | -------------------------------------------------------------------------------- /tests/x/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /auxiliary_tests/node_modules/Bar.js: -------------------------------------------------------------------------------- 1 | /* @providesModule Bar */ 2 | -------------------------------------------------------------------------------- /auxiliary_tests/node_modules/Foo_.js: -------------------------------------------------------------------------------- 1 | /* @providesModule Foo */ 2 | -------------------------------------------------------------------------------- /auxiliary_tests/type_test.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var _:number = XXX; 3 | -------------------------------------------------------------------------------- /src/dts/tests/numbered_keys/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | declarations 3 | -------------------------------------------------------------------------------- /tests/annot/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/annot/other.js: -------------------------------------------------------------------------------- 1 | class C { } 2 | module.exports = (C: any); 3 | -------------------------------------------------------------------------------- /tests/arith/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/arrays/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/arrows/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/async/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/autocomplete/autocomplete.exp: -------------------------------------------------------------------------------- 1 | num number 2 | str string 3 | -------------------------------------------------------------------------------- /tests/break/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/classes/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/classes/D.js: -------------------------------------------------------------------------------- 1 | class D { } 2 | class E { } 3 | new E().x 4 | -------------------------------------------------------------------------------- /tests/closure/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/conditional/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | -------------------------------------------------------------------------------- /tests/cycle/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/date/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/demo/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/demo/1/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/demo/2/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/deps/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/encaps/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/equals/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/for/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/funrec/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/get-def/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/graphql/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/indexer/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/init/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/iter/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/lib/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/libconfig/libA.js: -------------------------------------------------------------------------------- 1 | declare function foo(x: number): void; 2 | -------------------------------------------------------------------------------- /tests/libconfig/libB.js: -------------------------------------------------------------------------------- 1 | declare function bar(x: string): void; 2 | -------------------------------------------------------------------------------- /tests/literal/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/locals/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/logical/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/loners/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/misc/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/modules/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/node_tests/package_file/bar_lib/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = 0; 2 | -------------------------------------------------------------------------------- /tests/parse/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/path/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/poly/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/refi/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/regexp/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/replace/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/return/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/seal/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/sealed/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/static_overload/static_overload.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/statics/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/strict/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/strict_requires/A.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | module.exports = 0; 3 | -------------------------------------------------------------------------------- /tests/suggest/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/super/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/switch/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/symbol/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/this/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/tuples/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/unicode/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/union/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/value/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/window/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/yield/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/abnormal/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/annot/test.js: -------------------------------------------------------------------------------- 1 | var C = require('./other'); 2 | ((0: C): string); 3 | -------------------------------------------------------------------------------- /tests/arraylib/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/builtins/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/callable/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/commonjs/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/commonjs/Rel.js: -------------------------------------------------------------------------------- 1 | 2 | var f = require('./Abs'); 3 | 4 | f(0); 5 | -------------------------------------------------------------------------------- /tests/constructor/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/docblock/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/enumerror/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/es6modules/B.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | exports.numberValue = 42; 4 | -------------------------------------------------------------------------------- /tests/extensions/bar.jsx: -------------------------------------------------------------------------------- 1 | module.exports = function (p: string) {} 2 | -------------------------------------------------------------------------------- /tests/extensions/foo.js: -------------------------------------------------------------------------------- 1 | var imp = require('./bar'); 2 | imp(1337); 3 | -------------------------------------------------------------------------------- /tests/fixpoint/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/generics/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/instanceof/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/interface/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/intersection/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/keyvalue/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/librec/lib/A/libA.js: -------------------------------------------------------------------------------- 1 | declare function foo(x: number): void; 2 | -------------------------------------------------------------------------------- /tests/librec/lib/B/libB.js: -------------------------------------------------------------------------------- 1 | declare function bar(x: string): void; 2 | -------------------------------------------------------------------------------- /tests/mixins/Bar.js: -------------------------------------------------------------------------------- 1 | var Bar = { x: 0 }; 2 | module.exports = Bar; 3 | -------------------------------------------------------------------------------- /tests/more_annot/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/more_classes/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/more_path/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/more_react/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/more_statics/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/namespace/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/node_tests/basic_package/bar_lib/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/package_file/bar_lib.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar_lib"; 2 | -------------------------------------------------------------------------------- /tests/nullable/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/object_api/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/object_api/a.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { a() {} }; -------------------------------------------------------------------------------- /tests/optional/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/plsummit/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/promises/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/qualified/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/reflection/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/require/B.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | exports.numberValue = 42; 4 | -------------------------------------------------------------------------------- /tests/static_overload/test.js: -------------------------------------------------------------------------------- 1 | var x: number = StaticOverload.foo(0); 2 | -------------------------------------------------------------------------------- /tests/type_param_variance/type_param_variance.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/typecast/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/undefined/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/weakmode/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /hack/utils/.gitignore: -------------------------------------------------------------------------------- 1 | # CMake/Makefile codegen file 2 | get_build_id.gen.c 3 | -------------------------------------------------------------------------------- /tests/ast_tokens/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: ast --tokens --pretty 2 | stdin: foo.js 3 | -------------------------------------------------------------------------------- /tests/destructuring/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/dump-types/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: dump-types --strip-root --json test.js 2 | -------------------------------------------------------------------------------- /tests/error_messages/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/more_generics/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/node_haste/node_modules/qux/corge/package.json: -------------------------------------------------------------------------------- 1 | { "main": "lib" } 2 | -------------------------------------------------------------------------------- /tests/number_constants/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/object_freeze/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/parse_error_haste/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/simple_arrays/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/strict_requires/B.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | module.exports = { foo: "" } 3 | -------------------------------------------------------------------------------- /tests/suppress/lib.js: -------------------------------------------------------------------------------- 1 | // $FlowFixMe 2 | declare var library_num: number; 3 | -------------------------------------------------------------------------------- /tests/type_param_variance/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | -------------------------------------------------------------------------------- /tests/type_param_variance2/type_param_variance2.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /src/dts/tests/union/declarations/union.d.ts: -------------------------------------------------------------------------------- 1 | declare var x : number | string; 2 | -------------------------------------------------------------------------------- /src/dts/tests/union/declarations/union.js.exp: -------------------------------------------------------------------------------- 1 | declare var x: number | string; 2 | -------------------------------------------------------------------------------- /src/stubs/haste_module_preprocessor.mli: -------------------------------------------------------------------------------- 1 | val preprocess_name: string -> string 2 | -------------------------------------------------------------------------------- /tests/builtin_uses/test2.js: -------------------------------------------------------------------------------- 1 | var o = require('./test'); 2 | (o.foo: string); 3 | -------------------------------------------------------------------------------- /tests/demo/2/B.js: -------------------------------------------------------------------------------- 1 | var A = require('Demo'); 2 | 3 | var z = new A("42").getX(); 4 | -------------------------------------------------------------------------------- /tests/get-def/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: get-def example.js 12 10 --strip-root --json 2 | -------------------------------------------------------------------------------- /tests/issues-11/export.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | exports.x = 1; 3 | exports.y = ""; 4 | -------------------------------------------------------------------------------- /tests/missing_annotation/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | -------------------------------------------------------------------------------- /tests/node_tests/basic/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('./bar.js'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/basic_node_modules/node_modules/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/jsx/foo.jsx: -------------------------------------------------------------------------------- 1 | var x = require('./bar.jsx'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/replace/test.js: -------------------------------------------------------------------------------- 1 | var a = 0; 2 | 3 | function foo(x) { } 4 | 5 | foo(""); 6 | -------------------------------------------------------------------------------- /tests/type-at-pos/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: type-at-pos test.js 5 1 --strip-root --json 2 | -------------------------------------------------------------------------------- /hack/js/ocaml_sys.js: -------------------------------------------------------------------------------- 1 | 2 | function caml_sys_getenv () { 3 | return ''; 4 | } 5 | -------------------------------------------------------------------------------- /src/dts/tests/numbered_keys/numbered_keys.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var z : string = x["0"]; 3 | -------------------------------------------------------------------------------- /tests/commonjs/Abs.js: -------------------------------------------------------------------------------- 1 | 2 | function f(x:string) { } 3 | 4 | module.exports = f; 5 | -------------------------------------------------------------------------------- /tests/config_munging_underscores/config_munging_underscores.exp: -------------------------------------------------------------------------------- 1 | 2 | Found 0 errors 3 | -------------------------------------------------------------------------------- /tests/import_type/ExportsANumber.js: -------------------------------------------------------------------------------- 1 | /* @ flow */ 2 | 3 | export var numValue = 42; 4 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportCJSNamed_Number.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | exports.num = 42; 4 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportDefault_Number.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export default 42; 4 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportNamed_Number.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export var num = 42; 4 | -------------------------------------------------------------------------------- /tests/liberr/libs/type_error.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | declare function foo(x: number): Array; 3 | -------------------------------------------------------------------------------- /tests/optional/client_optional.js: -------------------------------------------------------------------------------- 1 | var qux = require('./optional'); 2 | 3 | qux(0); 4 | -------------------------------------------------------------------------------- /tests/optional/maybe.js: -------------------------------------------------------------------------------- 1 | function foo(x?: string): ?string { 2 | return x; 3 | } 4 | -------------------------------------------------------------------------------- /tests/overload/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | lib 3 | 4 | [options] 5 | module.system=haste 6 | -------------------------------------------------------------------------------- /tests/require/ProvidesModuleD.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule D 3 | * @flow 4 | */ 5 | -------------------------------------------------------------------------------- /tests/union/issue-323-lib.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | class Foo {} 3 | module.exports = Foo; 4 | -------------------------------------------------------------------------------- /src/dts/tests/enums/declarations/enums.d.ts: -------------------------------------------------------------------------------- 1 | declare enum Color { 2 | R, G, B 3 | } 4 | -------------------------------------------------------------------------------- /src/dts/tests/union/union.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var a : number = x; 3 | var b : typeof x = 5; 4 | -------------------------------------------------------------------------------- /tests/annot/issue-530.js: -------------------------------------------------------------------------------- 1 | function foo(...args: any) { } 2 | 3 | module.exports = foo; 4 | -------------------------------------------------------------------------------- /tests/declare_class/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | lib 3 | 4 | [options] 5 | module.system=haste 6 | -------------------------------------------------------------------------------- /tests/es6modules/ProvidesModuleD.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule D 3 | * @flow 4 | */ 5 | -------------------------------------------------------------------------------- /tests/forof/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/function/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/get-def/get-def.exp: -------------------------------------------------------------------------------- 1 | {"path":"library.js","line":5,"endline":7,"start":17,"end":3} 2 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportCJSDefault_Number.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = 42; 4 | -------------------------------------------------------------------------------- /tests/include/.flowconfig: -------------------------------------------------------------------------------- 1 | [include] 2 | ../lib 3 | [options] 4 | module.system=haste 5 | 6 | -------------------------------------------------------------------------------- /tests/incremental/dup_a.js: -------------------------------------------------------------------------------- 1 | /* @providesModule IncrModuleA */ 2 | 3 | var x:string = 0; 4 | -------------------------------------------------------------------------------- /tests/iterable/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/keyvalue/keyvalue.js: -------------------------------------------------------------------------------- 1 | var files = new FileList(); 2 | var x: number = files[""]; 3 | -------------------------------------------------------------------------------- /tests/module_redirect/A.js: -------------------------------------------------------------------------------- 1 | declare module A { 2 | declare function foo(): string; 3 | } 4 | -------------------------------------------------------------------------------- /tests/modules/cli2.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var f = require('./lib'); 4 | 5 | f("..."); 6 | -------------------------------------------------------------------------------- /tests/new_react/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | fakelib 3 | 4 | [options] 5 | module.system=haste 6 | -------------------------------------------------------------------------------- /tests/node_tests/basic_node_modules/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('bar.js'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/package_file_node_modules/node_modules/bar_lib.js: -------------------------------------------------------------------------------- 1 | module.exports = 0; 2 | -------------------------------------------------------------------------------- /tests/node_tests/path_package/node_modules/bar_lib/src/lib/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/object_api/c.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var c = require('./b'); 4 | c.a(); 5 | c.foo(); -------------------------------------------------------------------------------- /tests/private/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | munge_underscores=true 4 | -------------------------------------------------------------------------------- /tests/qualified/qualified.js: -------------------------------------------------------------------------------- 1 | class C { } 2 | var M = { C: C }; 3 | 4 | var x:M.C = 0; 5 | -------------------------------------------------------------------------------- /tests/traces/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | traces=3 4 | strip_root=true -------------------------------------------------------------------------------- /tests/typeof/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/yield/yield_arrow_error2.js: -------------------------------------------------------------------------------- 1 | function * f () { 2 | var e = () => yield 1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/ast_tokens/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/autocomplete/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/autocomplete/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: autocomplete --strip-root foo.js 10 5 2 | stdin: foo.js 3 | -------------------------------------------------------------------------------- /tests/classes/A.js: -------------------------------------------------------------------------------- 1 | class A { 2 | foo(x:number):void { } 3 | } 4 | 5 | module.exports = A; 6 | -------------------------------------------------------------------------------- /tests/deps/C.js: -------------------------------------------------------------------------------- 1 | require('./D'); 2 | require('./E'); 3 | require('./F'); 4 | require('./G'); 5 | -------------------------------------------------------------------------------- /tests/import_type/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/import_typeof/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/incremental/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*dup.* 3 | [options] 4 | module.system=haste 5 | 6 | -------------------------------------------------------------------------------- /tests/namespace/client.js: -------------------------------------------------------------------------------- 1 | var ns = require('./namespace') 2 | 3 | var bar: string = ns.foo 4 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules/node_modules/bar_lib/src/lib/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/path_package/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('bar_lib/src/lib'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/object_assign/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/plsummit/import_class.js: -------------------------------------------------------------------------------- 1 | var C = require('./export_class'); 2 | 3 | var c = new C(""); 4 | -------------------------------------------------------------------------------- /tests/refinements/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | [libs] 5 | lib.js 6 | -------------------------------------------------------------------------------- /tests/regexp/regexp.js: -------------------------------------------------------------------------------- 1 | var patt=/Hello/g 2 | var match:number = patt.test("Hello world!"); 3 | -------------------------------------------------------------------------------- /tests/suppress_traces/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: check --all --strip-root --show-all-errors --traces 10 2 | -------------------------------------------------------------------------------- /tests/window/window2.js: -------------------------------------------------------------------------------- 1 | /* @providesModule Window2 */ 2 | 3 | module.exports = window.parent; 4 | -------------------------------------------------------------------------------- /tests/yield/yield_arrow_error.js: -------------------------------------------------------------------------------- 1 | function * f () { 2 | var e = () => { yield 1; }; 3 | } 4 | -------------------------------------------------------------------------------- /src/dts/tests/numbered_keys/declarations/numbered_keys.d.ts: -------------------------------------------------------------------------------- 1 | declare var x : {0: number; 1: string}; 2 | -------------------------------------------------------------------------------- /tests/autocomplete_json/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/call_properties/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/modules/cli.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var f = require('./lib'); 4 | 5 | var y:number = f(0); 6 | -------------------------------------------------------------------------------- /tests/more_annot/client_object.js: -------------------------------------------------------------------------------- 1 | var o = require('./object'); 2 | 3 | var a:number = o.w.z.y; 4 | -------------------------------------------------------------------------------- /tests/node_tests/basic_node_modules_with_path/node_modules/bar_lib/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/basic_package/bar_lib/package.json: -------------------------------------------------------------------------------- 1 | { "name": "bar_lib", 2 | "main": "./bar.js" } 3 | -------------------------------------------------------------------------------- /tests/node_tests/package_file/bar_lib/package.json: -------------------------------------------------------------------------------- 1 | { "name": "bar_lib", 2 | "main": "./bar.js" } 3 | -------------------------------------------------------------------------------- /tests/node_tests/package_file_node_modules/foo/node_modules/bar_lib/bar.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/seal/imp.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var imp = require('./obj_annot'); 4 | imp({ name: "imp" }); 5 | -------------------------------------------------------------------------------- /tests/super/import.js: -------------------------------------------------------------------------------- 1 | class D { 2 | foo(): number { return 0; } 3 | } 4 | module.exports = D; 5 | -------------------------------------------------------------------------------- /tests/type_only_vars/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/type_param_variance2/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | libs/ 3 | 4 | [options] 5 | module.system=haste 6 | -------------------------------------------------------------------------------- /tests/union/test-lib.js: -------------------------------------------------------------------------------- 1 | /* @providesModule test-lib */ 2 | 3 | class C { } 4 | module.exports = C; 5 | -------------------------------------------------------------------------------- /tests/window/window1.js: -------------------------------------------------------------------------------- 1 | /* 2 | @providesModule Window1 3 | */ 4 | module.exports = window.history; 5 | -------------------------------------------------------------------------------- /src/dts/tests/functions/functions.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var x: C = f (5); 3 | var y: string = f(1, "test"); 4 | -------------------------------------------------------------------------------- /tests/autocomplete_json/.testconfig: -------------------------------------------------------------------------------- 1 | cmd: autocomplete --json --strip-root foo.js 10 5 2 | stdin: foo.js 3 | -------------------------------------------------------------------------------- /tests/auxiliary/real_node_modules/symlink_lib_outside_root/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { bar: "bar" }; 2 | -------------------------------------------------------------------------------- /tests/classes/B.js: -------------------------------------------------------------------------------- 1 | var A = require('./A'); 2 | 3 | class B extends A { } 4 | 5 | module.exports = B; 6 | -------------------------------------------------------------------------------- /tests/cycle/A.js: -------------------------------------------------------------------------------- 1 | var B = require('./B'); 2 | 3 | class A extends B { } 4 | 5 | module.exports = A; 6 | -------------------------------------------------------------------------------- /tests/cycle/B.js: -------------------------------------------------------------------------------- 1 | var A = require('./A'); 2 | 3 | //class B extends A { } 4 | 5 | module.exports = B; 6 | -------------------------------------------------------------------------------- /tests/cycle/cycle.exp: -------------------------------------------------------------------------------- 1 | 2 | B.js:5:18,18: identifier B 3 | Could not resolve name 4 | 5 | Found 1 error 6 | -------------------------------------------------------------------------------- /tests/error_messages/errors.js: -------------------------------------------------------------------------------- 1 | if (typeof define === 'function' && define.amd) { } 2 | 3 | Object(0); 4 | -------------------------------------------------------------------------------- /tests/init/nullable-init.js: -------------------------------------------------------------------------------- 1 | var o: {x: ?number} = { x: null }; 2 | var a: Array = [null,null]; 3 | -------------------------------------------------------------------------------- /tests/node_tests/basic_file/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('./bar'); // bar.js does not work 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/basic_node_modules_with_path/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('bar_lib/bar'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/jsx_file/foo.jsx: -------------------------------------------------------------------------------- 1 | var x = require('./bar'); // bar.js does not work 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('bar_lib/src/lib/bar'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_short_main/node_modules/bar_lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_symlinks/node_modules/symlink_lib: -------------------------------------------------------------------------------- 1 | ../real_node_modules/symlink_lib -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_without_main/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('bar_lib'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_without_main/node_modules/bar_lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = "bar"; 2 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_without_main/node_modules/bar_lib/package.json: -------------------------------------------------------------------------------- 1 | {"name":"bar_lib"} 2 | -------------------------------------------------------------------------------- /tests/refinements/lib.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | declare var BAZ: {stuff?: (x: number) => void} | void; 4 | -------------------------------------------------------------------------------- /tests/structural_subtyping/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/undefined/undefined2.js: -------------------------------------------------------------------------------- 1 | var id; 2 | var name = id ? 'John' : undefined; 3 | module.exports = name; 4 | -------------------------------------------------------------------------------- /src/dts/tests/classes/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/classes/classes.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var a : C = new D(); 3 | var a : D = new C(); // Error: C ~> D 4 | -------------------------------------------------------------------------------- /src/dts/tests/enums/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/modules/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/union/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/async/async_promise.js: -------------------------------------------------------------------------------- 1 | async function f(): Promise { 2 | return Promise.resolve(1); 3 | } 4 | -------------------------------------------------------------------------------- /tests/builtin_uses/test.js: -------------------------------------------------------------------------------- 1 | var o = Object.freeze({ foo: 0 }); 2 | (o.foo: string); 3 | module.exports = o; 4 | -------------------------------------------------------------------------------- /tests/class_property_initializers/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/class_subtyping/test.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | class A {} 3 | class B {} 4 | 5 | module.exports = { A, B }; 6 | -------------------------------------------------------------------------------- /tests/classes/loc.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | type Foo = number 4 | 5 | class Foo {} // error, shadows type Foo 6 | -------------------------------------------------------------------------------- /tests/config_munging_underscores2/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_DefaultAndNamed.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export default 42; 4 | export var str = 'asdf'; 5 | -------------------------------------------------------------------------------- /tests/getters_and_setters_disabled/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/import_type/issue-359.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | class ClassFoo6 {}; 4 | 5 | export default ClassFoo6; 6 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_short_main/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('bar_lib'); 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/suppress_bad/suppress_bad.exp: -------------------------------------------------------------------------------- 1 | .flowconfig:8 Invalid regex for suppress_comment: [ class not closed by ] 2 | -------------------------------------------------------------------------------- /hack/third-party/core/VERSION: -------------------------------------------------------------------------------- 1 | 112.01.00 of Jane Street's core_kernel (https://github.com/janestreet/core_kernel) 2 | -------------------------------------------------------------------------------- /hack/third-party/inotify/origin.txt: -------------------------------------------------------------------------------- 1 | http://projects.snarc.org/ocaml-inotify/download/ocaml_inotify-1.0.tar.bz2 2 | -------------------------------------------------------------------------------- /src/dts/tests/functions/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/modules2/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/type_alias/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/arith/mult.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function num(x:number) { } 4 | 5 | num(null * 1); 6 | num(1 * null); 7 | -------------------------------------------------------------------------------- /tests/callable/primitives.js: -------------------------------------------------------------------------------- 1 | var x = Boolean(4); 2 | function foo(fn:(value:any)=>boolean) { } 3 | foo(Boolean); 4 | -------------------------------------------------------------------------------- /tests/config_module_name_rewrite_node/Exists.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { 4 | numVal: 42 5 | }; 6 | -------------------------------------------------------------------------------- /tests/dump-types/import.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var num = 42; 3 | function bar() { } 4 | bar(); 5 | module.exports = num; 6 | -------------------------------------------------------------------------------- /tests/incremental/b.js: -------------------------------------------------------------------------------- 1 | /* @providesModule IncrModuleB 2 | @flow 3 | */ 4 | 5 | var A = require('IncrModuleA'); 6 | -------------------------------------------------------------------------------- /tests/lib_interfaces/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations 7 | 8 | [options] 9 | -------------------------------------------------------------------------------- /tests/more_annot/super.js: -------------------------------------------------------------------------------- 1 | class C { m() { } } 2 | class D extends C { } 3 | 4 | var d: { m(): void } = new D(); 5 | -------------------------------------------------------------------------------- /tests/new_react/Mixin.js: -------------------------------------------------------------------------------- 1 | /* @providesModule Mixin */ 2 | module.exports = { 3 | success: function() { } 4 | }; 5 | -------------------------------------------------------------------------------- /tests/object_is/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | module.system=haste 9 | -------------------------------------------------------------------------------- /tests/require/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | module.system=haste 9 | -------------------------------------------------------------------------------- /tests/spread/test4.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | function test(...nums: Array) {} 3 | 4 | test(0, ...[1, 2, 3]); 5 | -------------------------------------------------------------------------------- /tests/type-at-pos/import.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var num = 42; 3 | function bar() { } 4 | bar(); 5 | module.exports = num; 6 | -------------------------------------------------------------------------------- /tests/type-at-pos/test.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var str = require('./import'); 3 | function foo() { } 4 | foo(); 5 | str 6 | -------------------------------------------------------------------------------- /src/dts/tests/export_modules/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/import_commonjs/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/interface_var/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/nested_modules/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /src/dts/tests/var_interface/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | declarations/ 7 | [options] 8 | -------------------------------------------------------------------------------- /tests/any/.flowconfig: -------------------------------------------------------------------------------- 1 | [options] 2 | module.system=haste 3 | 4 | suppress_type=$FlowIssue 5 | suppress_type=$FlowFixMe 6 | -------------------------------------------------------------------------------- /tests/demo/1/f.js: -------------------------------------------------------------------------------- 1 | /* demo */ 2 | 3 | function f(x) { return 42/x; } 4 | 5 | var x = null; 6 | //... 7 | 8 | f(x); 9 | -------------------------------------------------------------------------------- /tests/es6modules/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | module.system=haste 9 | -------------------------------------------------------------------------------- /tests/export_type/cjs_with_types.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export type talias4 = number; 4 | 5 | module.exports = {} 6 | -------------------------------------------------------------------------------- /tests/export_type/types_only2.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export type talias1 = number; 4 | export type talias2 = number; 5 | -------------------------------------------------------------------------------- /tests/module_redirect/B.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule B 3 | * @flow 4 | */ 5 | 6 | module.exports = require('A'); 7 | -------------------------------------------------------------------------------- /tests/module_redirect/C.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule C 3 | * @flow 4 | */ 5 | 6 | module.exports = require('B'); 7 | -------------------------------------------------------------------------------- /tests/node_tests/basic_package/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('./bar_lib'); // 'bar_lib' does not work! 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/path_package/node_modules/bar_lib/src/lib/package.json: -------------------------------------------------------------------------------- 1 | { "name": "bar_lib", 2 | "main": "bar.js" } 3 | -------------------------------------------------------------------------------- /tests/plsummit/generics.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var r: number = 0; 4 | function foo(x: X): X { r = x; return x; } 5 | -------------------------------------------------------------------------------- /tests/require/ProvidesModuleA.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule A 3 | * @flow 4 | */ 5 | 6 | exports.numberValue = 42; 7 | -------------------------------------------------------------------------------- /tests/requireLazy/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | module.system=haste 9 | -------------------------------------------------------------------------------- /tests/suggest/lib.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function bar(w: number): number { return w; } 4 | 5 | module.exports = bar; 6 | -------------------------------------------------------------------------------- /tests/suppress_bad/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | suppress_comment=[ 9 | -------------------------------------------------------------------------------- /src/dts/tests/export_modules/export_modules.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var P = require("module-P"); 3 | var x : string = (new P.C()).y; 4 | -------------------------------------------------------------------------------- /tests/ignore_package/ignore_package.exp: -------------------------------------------------------------------------------- 1 | 2 | foo.js:8:9,29: underscore 3 | Required module not found 4 | 5 | Found 1 error 6 | -------------------------------------------------------------------------------- /tests/issues-11/import.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var e = require('./export'); 3 | var x: string = e.x; 4 | var y: number = e.y; 5 | -------------------------------------------------------------------------------- /tests/libconfig/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | libA.js 7 | libB.js 8 | 9 | [options] 10 | -------------------------------------------------------------------------------- /tests/liberr/a.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | // one error here, to verify lib errors sort to top. 5 | var x: string = 0; 6 | -------------------------------------------------------------------------------- /tests/literal/enum.js: -------------------------------------------------------------------------------- 1 | var APIKeys = { 2 | AGE: 'age', 3 | NAME: 'name', 4 | }; 5 | 6 | module.exports = APIKeys; 7 | -------------------------------------------------------------------------------- /tests/node_tests/node_tests.exp: -------------------------------------------------------------------------------- 1 | 2 | invalid_package_file/package.json:1:3,2: Unexpected end of input 3 | 4 | Found 1 error 5 | -------------------------------------------------------------------------------- /tests/node_tests/package_file/foo.js: -------------------------------------------------------------------------------- 1 | var x: string = require('./bar_lib'); // 'bar_lib' does not work! 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_short_main/node_modules/bar_lib/package.json: -------------------------------------------------------------------------------- 1 | {"name":"bar_lib", "main": "./index"} 2 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_symlinks/real_node_modules/symlink_lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { bar: "bar" }; 2 | -------------------------------------------------------------------------------- /tests/union/issue-323.js: -------------------------------------------------------------------------------- 1 | var Foo = require("./issue-323-lib"); 2 | var foo = new Foo(); 3 | var foostr: Foo | string = foo; 4 | -------------------------------------------------------------------------------- /examples/01_HelloWorld/hello.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(x) { 4 | return x*10; 5 | } 6 | 7 | foo("Hello, world!"); 8 | -------------------------------------------------------------------------------- /src/dts/tests/numbered_keys/declarations/numbered_keys.js.exp: -------------------------------------------------------------------------------- 1 | declare var x: {"0": number; 2 | "1": string;}; 3 | -------------------------------------------------------------------------------- /src/dts/tests/type_alias/type_alias.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var M = require('M'); 3 | var a : number = M.x; 4 | var b : typeof M.x = 5; 5 | -------------------------------------------------------------------------------- /src/parser/.gitignore: -------------------------------------------------------------------------------- 1 | lex_test 2 | parse_test 3 | lexer_flow.ml 4 | flow_parser.js 5 | perf_test 6 | pfff_test 7 | node_modules/ 8 | -------------------------------------------------------------------------------- /tests/dump-types/test.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var num = require('./import'); 3 | function foo() { } 4 | foo(); 5 | var a:string = num; 6 | -------------------------------------------------------------------------------- /tests/ignore_package/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*node_modules/underscore.* 3 | 4 | [include] 5 | 6 | [libs] 7 | 8 | [options] 9 | -------------------------------------------------------------------------------- /tests/liberr/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | libs/ 7 | 8 | [options] 9 | strip_root=true 10 | -------------------------------------------------------------------------------- /tests/librec/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | lib 7 | 8 | [options] 9 | module.system=haste 10 | -------------------------------------------------------------------------------- /tests/node_haste/node_haste.exp: -------------------------------------------------------------------------------- 1 | 2 | foo/bar/client.js:7:19,39: annotation 3 | Required module not found 4 | 5 | Found 1 error 6 | -------------------------------------------------------------------------------- /tests/node_tests/package_file_node_modules/foo/node_modules/bar_lib/package.json: -------------------------------------------------------------------------------- 1 | { "name": "bar_lib", 2 | "main": "./bar.js" } 3 | -------------------------------------------------------------------------------- /tests/union/fields.js: -------------------------------------------------------------------------------- 1 | class C { 2 | x: ?number|string; 3 | constructor() { 4 | this.x = null; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/version/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | 9 | [version] 10 | 0.1.0 11 | -------------------------------------------------------------------------------- /tests/version/version.exp: -------------------------------------------------------------------------------- 1 | .flowconfig:10 Wrong version of Flow. The config specifies version 0.1.0 but this is version 0.14.0 2 | -------------------------------------------------------------------------------- /tests/auxiliary/real_node_modules/symlink_lib_outside_root/package.json: -------------------------------------------------------------------------------- 1 | {"name": "symlink_lib_outside_root", "main": "./index.js"} 2 | -------------------------------------------------------------------------------- /tests/config_module_name_rewrite_node/node_modules/Exists/index.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { 4 | numVal: 42 5 | }; 6 | -------------------------------------------------------------------------------- /tests/config_munging_underscores/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | munge_underscores=true 9 | -------------------------------------------------------------------------------- /tests/node_tests/assert/assert.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var assert = require("assert") 4 | assert(true) // ok 5 | assert.ok(true) // ok 6 | -------------------------------------------------------------------------------- /tests/plsummit/arrays.js: -------------------------------------------------------------------------------- 1 | function foo(x) { return [x, x > 0, "number " + x]; } 2 | 3 | var [n, b, s] = foo(42); 4 | n * s.length; 5 | -------------------------------------------------------------------------------- /tests/suppress_traces/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | suppress_comment=.*\\$FlowFixMe.* 9 | -------------------------------------------------------------------------------- /src/dts/tests/functions/declarations/functions.d.ts: -------------------------------------------------------------------------------- 1 | function f(num:number, str:string):C; 2 | declare class C { 3 | x : number 4 | } 5 | -------------------------------------------------------------------------------- /tests/autocomplete/foo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | var obj = { 6 | num: 123, 7 | str: 'hello', 8 | }; 9 | 10 | obj. 11 | -------------------------------------------------------------------------------- /tests/classes/C.js: -------------------------------------------------------------------------------- 1 | var B = require('./B'); 2 | 3 | class C extends B { 4 | foo(x:string):void { } 5 | } 6 | 7 | module.exports = C; 8 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportCJSNamed_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo4 {} 6 | 7 | exports.ClassFoo4 = ClassFoo4; 8 | -------------------------------------------------------------------------------- /tests/module_redirect/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | A.js 7 | 8 | [options] 9 | module.system=haste 10 | -------------------------------------------------------------------------------- /tests/node_tests/package_file_node_modules/foo/foo.js: -------------------------------------------------------------------------------- 1 | var x: string = require('bar_lib'); // 'bar_lib' does not work! 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_symlinks/real_node_modules/symlink_lib/package.json: -------------------------------------------------------------------------------- 1 | {"name": "symlink_lib", "main": "./index.js"} 2 | -------------------------------------------------------------------------------- /tests/object_api/object_keys.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var obj = {one: 'one', two: 'two'}; 4 | var keys : Array = Object.keys(obj); 5 | -------------------------------------------------------------------------------- /tests/strict_requires/C.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var o = { 3 | A: require('./A'), 4 | ...require('./B'), 5 | }; 6 | module.exports = o; 7 | -------------------------------------------------------------------------------- /tests/strict_requires/D.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var C = require('./C'); 3 | var x: number = C.foo; 4 | var y: string = C.A; 5 | C.A = false; 6 | -------------------------------------------------------------------------------- /tests/throw/throw.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:9:16,21: string 3 | This type is incompatible with 4 | test.js:13:12,14: number 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/autocomplete_json/foo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | var obj = { 6 | num: 123, 7 | str: 'hello', 8 | }; 9 | 10 | obj. 11 | -------------------------------------------------------------------------------- /tests/loners/loners.exp: -------------------------------------------------------------------------------- 1 | 2 | loners.js:2:11,11: property z 3 | Property not found in 4 | loners.js:2:9,9: object literal 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/misc/G.js: -------------------------------------------------------------------------------- 1 | var a = { length: "duck" }; 2 | a.length = 123; 3 | a.length(); 4 | 5 | var b = [ 123 ]; 6 | b.length = "duck"; 7 | b.length(); 8 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_symlinks/node_modules/symlink_lib_outside_root: -------------------------------------------------------------------------------- 1 | ../../../auxiliary/real_node_modules/symlink_lib_outside_root -------------------------------------------------------------------------------- /tests/plsummit/export_class.js: -------------------------------------------------------------------------------- 1 | class C { 2 | x: number; 3 | constructor(x: number) { this.x = x; } 4 | } 5 | 6 | module.exports = C; 7 | -------------------------------------------------------------------------------- /tests/static_overload/lib/lib.js: -------------------------------------------------------------------------------- 1 | declare class StaticOverload { 2 | static foo(x: number): number; 3 | static foo(x: string): string; 4 | } 5 | -------------------------------------------------------------------------------- /tests/switch/switch.exp: -------------------------------------------------------------------------------- 1 | 2 | switch.js:23:19,20: string 3 | This type is incompatible with 4 | switch.js:28:13,15: number 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/symbol/symbol.js: -------------------------------------------------------------------------------- 1 | var FOO = Symbol(); 2 | var BAR = Symbol('bar'); 3 | 4 | // TODO: Expected error 5 | var WAT = Symbol('foo', 'bar'); 6 | -------------------------------------------------------------------------------- /tests/tuples/tuples.exp: -------------------------------------------------------------------------------- 1 | 2 | tuples.js:6:33,35: number 3 | This type is incompatible with 4 | tuples.js:6:17,22: string 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /examples/03_Null/nulls.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function length(x) { 4 | return x.length; 5 | } 6 | 7 | var total = length("Hello") + length(null); 8 | -------------------------------------------------------------------------------- /examples/05_DynamicCode/dynamic.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(x) { 4 | return x.length; 5 | } 6 | 7 | var res = foo("Hello") + foo(42); 8 | -------------------------------------------------------------------------------- /src/dts/tests/classes/declarations/classes.js.exp: -------------------------------------------------------------------------------- 1 | declare class C { 2 | x: number; 3 | } 4 | declare class D extends C { 5 | y: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/dts/tests/functions/declarations/functions.js.exp: -------------------------------------------------------------------------------- 1 | declare function f(num: number, str: string): C; 2 | declare class C { 3 | x: number; 4 | } 5 | -------------------------------------------------------------------------------- /tests/abnormal/return.js: -------------------------------------------------------------------------------- 1 | function bar(x:number) { } 2 | function foo() { 3 | var x = null; 4 | if (x == null) return; 5 | bar(x); 6 | } 7 | -------------------------------------------------------------------------------- /tests/ignore_package/node_modules/underscore/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "underscore", 3 | "main": "underscore.js", 4 | "version": "1.8.3" 5 | } 6 | -------------------------------------------------------------------------------- /tests/qualified/qualified.exp: -------------------------------------------------------------------------------- 1 | 2 | qualified.js:4:13,13: number 3 | This type is incompatible with 4 | qualified.js:4:7,9: C 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/seal/seal.exp: -------------------------------------------------------------------------------- 1 | 2 | obj_annot.js:4:18,19: property id 3 | Property not found in 4 | obj_annot.js:4:12,16: object type 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/shape/test.js: -------------------------------------------------------------------------------- 1 | type Foo = { 2 | field: number, 3 | } 4 | 5 | var x: {field?: number} = {}; 6 | var y: $Shape = x; 7 | (y.field: number) 8 | -------------------------------------------------------------------------------- /src/dts/tests/classes/declarations/classes.d.ts: -------------------------------------------------------------------------------- 1 | declare class C { 2 | x : number 3 | } 4 | 5 | declare class D extends C { 6 | y : string 7 | } 8 | -------------------------------------------------------------------------------- /src/dts/tests/type_alias/declarations/type_alias.d.ts: -------------------------------------------------------------------------------- 1 | declare module M { 2 | type NumString = number | string 3 | export var x : NumString 4 | } 5 | -------------------------------------------------------------------------------- /src/dts/tests/union/union.exp: -------------------------------------------------------------------------------- 1 | 2 | union.js:2:9,14: number 3 | This type is incompatible with 4 | [LIB] union.js:1:25,30: string 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/bounded_poly/scope.js: -------------------------------------------------------------------------------- 1 | function foo(x:X, y:Y):void { } 2 | foo(0, ""); 3 | 4 | function bar(x:X, y:Y): number { return y*0; } 5 | -------------------------------------------------------------------------------- /tests/declare_fun/declare_fun.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:7:6,10: boolean 3 | This type is incompatible with 4 | test.js:7:14,17: undefined 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/getters_and_setters_enabled/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | unsafe.enable_getters_and_setters=true 9 | -------------------------------------------------------------------------------- /tests/optional/undefined2.js: -------------------------------------------------------------------------------- 1 | var x; 2 | 3 | function foo(bar?) { 4 | x = bar; 5 | } 6 | 7 | function bar() { 8 | return x.duck; 9 | } 10 | -------------------------------------------------------------------------------- /tests/simple_arrays/simple_arrays.exp: -------------------------------------------------------------------------------- 1 | 2 | array.js:4:30,30: number 3 | This type is incompatible with 4 | array.js:8:18,23: string 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/typecast/typecast.exp: -------------------------------------------------------------------------------- 1 | 2 | typecast.js:7:14,18: string 3 | This type is incompatible with 4 | typecast.js:7:22,27: number 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/value/value.js: -------------------------------------------------------------------------------- 1 | var o = {}; 2 | o["x"] = 4; 3 | var y:string = o["x"]; 4 | 5 | var table: { [_: string]: number } = {}; 6 | table["x"] = "hello"; 7 | -------------------------------------------------------------------------------- /auxiliary_tests/module_test.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var Foo = require('Foo'); 3 | var Bar = require('Bar'); 4 | 5 | var x:number = Foo.x; 6 | var y:number = Bar.y; 7 | -------------------------------------------------------------------------------- /tests/config_module_name_rewrite_haste/Exists.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule Exists 3 | * @flow 4 | */ 5 | 6 | module.exports = { 7 | numVal: 42 8 | }; 9 | -------------------------------------------------------------------------------- /tests/declare_class/declare_class.js: -------------------------------------------------------------------------------- 1 | declare class C { 2 | static x: number; 3 | static foo(x: number): void; 4 | } 5 | 6 | C.x = ""; 7 | C.foo(""); 8 | -------------------------------------------------------------------------------- /tests/dictionary/test_client.js: -------------------------------------------------------------------------------- 1 | var o = require('./test'); 2 | 3 | o.foo = function (params) { 4 | return params.count; // error, number ~/~ string 5 | } 6 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportAllFrom_Source1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportAllFrom_Source1 3 | * @flow 4 | */ 5 | 6 | export var numberValue1 = 1; 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportAllFrom_Source2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportAllFrom_Source2 3 | * @flow 4 | */ 5 | 6 | export var numberValue1 = 1; 7 | -------------------------------------------------------------------------------- /tests/funrec/funrec.js: -------------------------------------------------------------------------------- 1 | function bar(x) { return x; } 2 | function foo() { 3 | return function bound() { 4 | return bar(bound); 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /tests/overload/union.js: -------------------------------------------------------------------------------- 1 | function foo (x: $Either,U>): Array { return []; } 2 | 3 | var x1:number = foo(0)[0]; 4 | var x2:string = foo([""])[0]; 5 | -------------------------------------------------------------------------------- /tests/yield/yield.exp: -------------------------------------------------------------------------------- 1 | 2 | yield_arrow_error.js:2:25,25: Unexpected number 3 | 4 | yield_arrow_error2.js:2:23,23: Unexpected number 5 | 6 | Found 2 errors 7 | -------------------------------------------------------------------------------- /hack/third-party/inotify/META: -------------------------------------------------------------------------------- 1 | version="1.0" 2 | description="Linux inotify" 3 | requires="unix" 4 | archive(byte)="inotify.cma" 5 | archive(native)="inotify.cmxa" 6 | -------------------------------------------------------------------------------- /src/dts/tests/modules2/modules2.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var M = require('M.N');; 3 | 4 | var x : M.C = new M.C(); 5 | var z : typeof M.x = x.y; 6 | var m : string = z; 7 | -------------------------------------------------------------------------------- /tests/abnormal/break-continue.js: -------------------------------------------------------------------------------- 1 | function foo() { 2 | while(true) { break; } 3 | } 4 | 5 | function bar() { 6 | L: do { continue L; } while(false) 7 | } 8 | -------------------------------------------------------------------------------- /tests/es6modules/ProvidesModuleCJSDefault.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule CJSDefault 3 | * @flow 4 | */ 5 | 6 | module.exports = { 7 | numberValue: 42 8 | }; 9 | -------------------------------------------------------------------------------- /tests/misc/F.js: -------------------------------------------------------------------------------- 1 | function fn2(x) { return x.length * 4; } 2 | fn2({length: 'hi'}); 3 | 4 | function foo(x: Array): string { 5 | return x.length; 6 | } 7 | -------------------------------------------------------------------------------- /tests/more_annot/more_annot.exp: -------------------------------------------------------------------------------- 1 | 2 | client_object.js:3:16,22: string 3 | This type is incompatible with 4 | client_object.js:3:7,12: number 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/object_assign/non_objects.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | Object.assign("123", {a: "foo"}); 4 | Object.assign(123, {a: "foo"}); 5 | Object.assign({a: "foo"}, 123); 6 | -------------------------------------------------------------------------------- /tests/optional/undefined.js: -------------------------------------------------------------------------------- 1 | var x; 2 | 3 | function foo(bar? = undefined) { 4 | x = bar; 5 | } 6 | 7 | function bar() { 8 | return x.duck; 9 | } 10 | -------------------------------------------------------------------------------- /tests/path/while.js: -------------------------------------------------------------------------------- 1 | var x = 1; 2 | while(typeof x == "number" || typeof x == "string") { 3 | x = x + 1; 4 | if (true) x = ""; 5 | } 6 | var z:number = x; 7 | -------------------------------------------------------------------------------- /src/dts/tests/modules2/declarations/modules2.d.ts: -------------------------------------------------------------------------------- 1 | declare module M.N { 2 | export var x: number 3 | export class C { 4 | y : typeof x 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/class_subtyping/test2.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var I = require("./test.js"); 3 | 4 | class C extends I.A {} 5 | 6 | var x: I.A = new C(); 7 | var y: I.B = new C(); 8 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportFrom_Source1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportFrom_Source1 3 | * @flow 4 | */ 5 | 6 | export var numberValue1 = 1, numberValue2 = 2; 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportFrom_Source2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportFrom_Source2 3 | * @flow 4 | */ 5 | 6 | export var numberValue1 = 1, numberValue2 = 2; 7 | -------------------------------------------------------------------------------- /tests/interface/interface.js: -------------------------------------------------------------------------------- 1 | declare class C { x: number; } 2 | 3 | var x: string = new C().x; 4 | 5 | interface I { x: number; } 6 | 7 | var i = new I(); // error 8 | -------------------------------------------------------------------------------- /tests/mixins/test.js: -------------------------------------------------------------------------------- 1 | var Bar = require('./Bar'); 2 | 3 | class Foo extends mixin(Bar) { 4 | m() { 5 | var x: string = this.x; 6 | this.y = ""; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/object_api/b.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var a = require('./a'); 4 | var b = Object.assign({ bar() {}, ...{} }, a); 5 | b.a(); // works here 6 | module.exports = b; 7 | -------------------------------------------------------------------------------- /tests/overload/test.js: -------------------------------------------------------------------------------- 1 | function foo() { 2 | var output = new FakeUint8Array(); 3 | output.set(new FakeUint8Array(), 0); // matches one of the overloads of set 4 | } 5 | -------------------------------------------------------------------------------- /tests/spread/test2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | function foo(o) { 6 | bar({...o}); 7 | } 8 | function bar(_: {foo:number}) { } 9 | foo({foo: 42}); 10 | -------------------------------------------------------------------------------- /tests/statics/funstatics.js: -------------------------------------------------------------------------------- 1 | function C() { } 2 | C.prototype.f = function() { return C.g(0); } 3 | C.g = function(x) { return x; }; 4 | 5 | var x:string = new C().f(); 6 | -------------------------------------------------------------------------------- /examples/02_TypeAnnotations/type_annotations.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(x: string, y: number): string { 4 | return x.length * y; 5 | } 6 | 7 | foo("Hello", 42); 8 | -------------------------------------------------------------------------------- /src/dts/tests/interface_var/interface_var.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var agelimit: number = adult; 3 | var another_attempt: number = adult.minage; 4 | var tom : adult = new adult(); 5 | -------------------------------------------------------------------------------- /src/dts/tests/type_alias/type_alias.exp: -------------------------------------------------------------------------------- 1 | 2 | type_alias.js:3:9,14: number 3 | This type is incompatible with 4 | [LIB] type_alias.js:3:37,42: string 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /src/dts/tests/var_interface/var_interface.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var agelimit: number = adult; 3 | var another_attempt: number = adult.minage; 4 | var tom : adult = new adult(); 5 | -------------------------------------------------------------------------------- /tests/constructor/constructor.exp: -------------------------------------------------------------------------------- 1 | 2 | constructor.js:6:19,24: return undefined 3 | This type is incompatible with 4 | constructor.js:6:19,24: number 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/constructor/constructor.js: -------------------------------------------------------------------------------- 1 | class C { 2 | constructor() { } 3 | } 4 | 5 | class D { 6 | constructor():number { } 7 | } 8 | 9 | module.exports = C; 10 | -------------------------------------------------------------------------------- /tests/node_haste/node_modules/qux/docblock.js: -------------------------------------------------------------------------------- 1 | var x = 0; 2 | /* 3 | This @providesModule annotation is unreachable, since it 4 | follows an executable statement. 5 | */ 6 | -------------------------------------------------------------------------------- /tests/requireLazy/A.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule A 3 | * @flow 4 | */ 5 | 6 | module.exports = { 7 | numberValueA: 1, 8 | stringValueA: "someString" 9 | }; 10 | -------------------------------------------------------------------------------- /tests/requireLazy/B.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule B 3 | * @flow 4 | */ 5 | 6 | module.exports = { 7 | numberValueB: 1, 8 | stringValueB: "someString" 9 | }; 10 | -------------------------------------------------------------------------------- /auxiliary/lib/auxiliary.js: -------------------------------------------------------------------------------- 1 | declare var XXX: string; 2 | declare module Foo { 3 | declare var x: string; 4 | } 5 | declare module Bar { 6 | declare var y: string; 7 | } 8 | -------------------------------------------------------------------------------- /examples/01_HelloWorld/answer/hello.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(x) { 4 | return x*10; 5 | } 6 | 7 | // This is fine, because we're passing a number now 8 | foo(10); 9 | -------------------------------------------------------------------------------- /src/dts/tests/import_commonjs/import_commonjs.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var P = require("module-P"); 3 | var x : string = (new P.C()).y; 4 | var M = require("M"); 5 | var z: number = M.m; 6 | -------------------------------------------------------------------------------- /src/dts/tests/numbered_keys/numbered_keys.exp: -------------------------------------------------------------------------------- 1 | 2 | numbered_keys.js:2:18,23: number 3 | This type is incompatible with 4 | numbered_keys.js:2:9,14: string 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_AnonFunction1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_AnonFunction1 3 | * @flow 4 | */ 5 | 6 | export default function():number { return 42; } 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_AnonFunction2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_AnonFunction2 3 | * @flow 4 | */ 5 | 6 | export default function():number { return 42; } 7 | -------------------------------------------------------------------------------- /tests/node_tests/path_node_modules_with_symlinks/foo.js: -------------------------------------------------------------------------------- 1 | var x = require('symlink_lib'); 2 | var y = require('symlink_lib_outside_root'); 3 | console.log(x); 4 | console.log(y); 5 | -------------------------------------------------------------------------------- /tests/optional/optional_param3.js: -------------------------------------------------------------------------------- 1 | function foo(x?: number) {} 2 | foo(undefined); // ok 3 | 4 | function bar(x = "bar"): string { 5 | return x; 6 | } 7 | bar(undefined); // ok 8 | -------------------------------------------------------------------------------- /tests/super/test.js: -------------------------------------------------------------------------------- 1 | var D = require('./import'); 2 | class C extends D { 3 | constructor() { return super(); } 4 | foo() { return super.foo(); } 5 | } 6 | module.exports = C; 7 | -------------------------------------------------------------------------------- /src/common/FlowJSON.mli: -------------------------------------------------------------------------------- 1 | open Spider_monkey_ast 2 | open Utils 3 | 4 | val parse_object: 5 | string -> 6 | string -> 7 | Expression.t SMap.t * (Loc.t * Parser_flow.Error.t) list 8 | -------------------------------------------------------------------------------- /src/dts/tests/interface_var/declarations/interface_var.js.exp: -------------------------------------------------------------------------------- 1 | declare class adult { 2 | height: number; 3 | age: number; 4 | static minage: number; 5 | new(): adult; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /src/dts/tests/var_interface/declarations/var_interface.js.exp: -------------------------------------------------------------------------------- 1 | declare class adult { 2 | height: number; 3 | age: number; 4 | static minage: number; 5 | new(): adult; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/commonjs/commonjs.exp: -------------------------------------------------------------------------------- 1 | 2 | Rel.js:4:1,4: function call 3 | Error: 4 | Rel.js:4:3,3: number 5 | This type is incompatible with 6 | Abs.js:2:14,19: string 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_AnonClass1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_AnonClass1 3 | * @flow 4 | */ 5 | 6 | export default class { givesANum(): number { return 42; }}; 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_AnonClass2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_AnonClass2 3 | * @flow 4 | */ 5 | 6 | export default class { givesANum(): number { return 42; }}; 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_NamedFunction1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_NamedFunction1 3 | * @flow 4 | */ 5 | 6 | export default function foo():number { return 42; } 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_NamedFunction2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_NamedFunction2 3 | * @flow 4 | */ 5 | 6 | export default function foo():number { return 42; } 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportAllFrom_Intermediary1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportAllFrom_Intermediary1 3 | * @flow 4 | */ 5 | 6 | export * from "ES6_ExportAllFrom_Source1"; 7 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportAllFrom_Intermediary2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportAllFrom_Intermediary2 3 | * @flow 4 | */ 5 | 6 | export * from "ES6_ExportAllFrom_Source2"; 7 | -------------------------------------------------------------------------------- /tests/es6modules/ProvidesModuleES6Default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6Default 3 | * @flow 4 | */ 5 | 6 | /* 7 | export default { 8 | numberValue: 42, 9 | }; 10 | */ 11 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportNamed_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo2 { 6 | returnsANumber(): number { return 42; } 7 | } 8 | 9 | export {ClassFoo2}; 10 | -------------------------------------------------------------------------------- /tests/more_annot/proto.js: -------------------------------------------------------------------------------- 1 | function Foo() { this.x = 0; } 2 | Foo.prototype.m = function() { } 3 | 4 | var o1: { x: number; m(): void } = new Foo(); 5 | 6 | var o2: Foo = new Foo(); 7 | -------------------------------------------------------------------------------- /tests/overload/lib/lib.js: -------------------------------------------------------------------------------- 1 | declare class FakeUint8Array { 2 | set(index: number, value: number): void; 3 | set(array: FakeUint8Array | Array, offset?: number): void; 4 | } 5 | -------------------------------------------------------------------------------- /tests/private/private.exp: -------------------------------------------------------------------------------- 1 | 2 | private.js:11:22,28: property _x 3 | Error: 4 | private.js:11:27,28: property _x 5 | Property not found in 6 | private.js:8:7,7: B 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/weakmode/weakmode.exp: -------------------------------------------------------------------------------- 1 | 2 | should_fail_without_weak.js:5:10,16: string 3 | This type is incompatible with 4 | should_fail_without_weak.js:9:10,32: number 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/arrays/arrays.exp: -------------------------------------------------------------------------------- 1 | 2 | Arrays.js:10:1,9: function call 3 | Error: 4 | Arrays.js:7:8,8: number 5 | This type is incompatible with 6 | Arrays.js:4:16,21: string 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_NamedClass2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_NamedClass2 3 | * @flow 4 | */ 5 | 6 | export default class Foo { givesANum(): number { return 42; }}; 7 | -------------------------------------------------------------------------------- /tests/extensions/extensions.exp: -------------------------------------------------------------------------------- 1 | 2 | foo.js:2:1,9: function call 3 | Error: 4 | foo.js:2:5,8: number 5 | This type is incompatible with 6 | bar.jsx:1:31,36: string 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/method_properties/test.js: -------------------------------------------------------------------------------- 1 | class C { 2 | C() { } 3 | foo() { } 4 | static bar() { } 5 | qux() { this.constructor.x; } 6 | } 7 | C.x; 8 | (new C).foo.x; 9 | C.bar.x; 10 | -------------------------------------------------------------------------------- /tests/nullable/simple_nullable.js: -------------------------------------------------------------------------------- 1 | function foo(x:?string) {} 2 | function bar(x:?number) {} 3 | foo('hmm'); 4 | bar('hmm'); 5 | 6 | function fn(data: ?{}) {} 7 | fn({some: 'literal'}); 8 | -------------------------------------------------------------------------------- /tests/parse_error_node/parse_error_node.exp: -------------------------------------------------------------------------------- 1 | 2 | Client.js:8:9,29: Imported.js 3 | Required module not found 4 | 5 | Imported.js:6:31,31: Unexpected token ILLEGAL 6 | 7 | Found 2 errors 8 | -------------------------------------------------------------------------------- /tests/type_only_vars/A.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class Foo { 6 | } 7 | 8 | class Bar { 9 | } 10 | 11 | module.exports = { 12 | Foo: Foo, 13 | Bar: Bar 14 | }; 15 | -------------------------------------------------------------------------------- /tests/undefined/undefined.exp: -------------------------------------------------------------------------------- 1 | 2 | undefined.js:3:5,11: call of method foo 3 | Method cannot be called on possibly undefined value 4 | undefined.js:3:5,5: undefined 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /tests/union/issue-324.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | class Foo{}; 3 | class Bar{}; 4 | 5 | var foostr: Foo | string = new Foo(); 6 | var barstr: Bar | string = new Bar(); 7 | 8 | foostr = barstr; 9 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportDefault_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo1 { 6 | returnsANumber(): number { return 42; } 7 | } 8 | 9 | export default ClassFoo1; 10 | -------------------------------------------------------------------------------- /tests/lib_interfaces/declarations/underscore.js: -------------------------------------------------------------------------------- 1 | interface C { 2 | foo(): CArrays; 3 | bar(): C; 4 | } 5 | interface CArrays extends C> { 6 | bar(): C; 7 | } 8 | -------------------------------------------------------------------------------- /tests/librec/librec.exp: -------------------------------------------------------------------------------- 1 | 2 | libtest.js:2:1,8: function call 3 | Error: 4 | libtest.js:2:5,7: number 5 | This type is incompatible with 6 | [LIB] libB.js:1:25,30: string 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/module_redirect/D.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule D 3 | * @flow 4 | */ 5 | 6 | var bar1: string = require('A'); 7 | var bar2: string = require('B'); 8 | var bar3: string = require('C'); 9 | -------------------------------------------------------------------------------- /tests/parse/no_parse_error.js: -------------------------------------------------------------------------------- 1 | /* 2 | @flow 3 | */ 4 | 5 | var x = 'Test'; 6 | var y = 5 / x; 7 | 8 | var z: { 9 | type: number, 10 | y: string 11 | } = {type: 1, y: 'hey'}; 12 | -------------------------------------------------------------------------------- /tests/refi/switch.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | function foo(a,b,c) { 3 | switch (c) { 4 | case a.x.y: // OK 5 | case b.x.y: // OK 6 | return; 7 | default: 8 | return; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/refinements/null.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function null_bogus_comparison() { 4 | if (100 * null) { 5 | return; 6 | } 7 | if (null * 100) { 8 | return; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/reflection/type.js: -------------------------------------------------------------------------------- 1 | declare var a: number; 2 | var b: typeof a = "..."; 3 | var c: typeof a = "..."; 4 | 5 | type T = number; 6 | var x:T = "..."; 7 | 8 | // what about recursive unions? 9 | -------------------------------------------------------------------------------- /src/common/span.mli: -------------------------------------------------------------------------------- 1 | val make_span: 2 | Loc.position -> 3 | Loc.position -> 4 | Loc.t 5 | 6 | val string_of_span: Loc.t -> string 7 | 8 | module SpanMap : Utils.MapSig with type key = Loc.t 9 | -------------------------------------------------------------------------------- /src/dts/tests/enums/enums.exp: -------------------------------------------------------------------------------- 1 | 2 | enums.js:8:13,19: property R 3 | Error: 4 | enums.js:4:8,13: string 5 | This type is incompatible with 6 | [LIB] enums.js:3:14,19: number 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /src/dts/tests/interface_var/interface_var.exp: -------------------------------------------------------------------------------- 1 | 2 | interface_var.js:2:15,20: number 3 | This type is incompatible with 4 | [LIB] interface_var.js:1:1,6:1: class type: adult 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /src/dts/tests/var_interface/var_interface.exp: -------------------------------------------------------------------------------- 1 | 2 | var_interface.js:2:15,20: number 3 | This type is incompatible with 4 | [LIB] var_interface.js:1:1,6:1: class type: adult 5 | 6 | Found 1 error 7 | -------------------------------------------------------------------------------- /src/parser/.npmignore: -------------------------------------------------------------------------------- 1 | *.ml 2 | *.mll 3 | TARGETS 4 | Makefile 5 | _build/ 6 | facebook/ 7 | lex_test 8 | parse_test 9 | perf_test 10 | pfff_test 11 | github-README.md 12 | npm-README.md 13 | -------------------------------------------------------------------------------- /tests/async/await_not_in_async.js: -------------------------------------------------------------------------------- 1 | // note: currently, await-within-async enforcement is a 2 | // done by the parser, which bails after a single error. 3 | 4 | function f() { 5 | await 1; 6 | } 7 | -------------------------------------------------------------------------------- /tests/libconfig/libconfig.exp: -------------------------------------------------------------------------------- 1 | 2 | libtest.js:2:1,8: function call 3 | Error: 4 | libtest.js:2:5,7: number 5 | This type is incompatible with 6 | [LIB] libB.js:1:25,30: string 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/method_properties/method_properties.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:7:1,3: property x 3 | Error: 4 | test.js:7:3,3: property x 5 | Property not found in 6 | test.js:1:7,7: statics of C 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/more_annot/object.js: -------------------------------------------------------------------------------- 1 | var o1 = { x: 0, y: "" }; 2 | var o2 = { z: o1 } 3 | 4 | var o3 = {}; 5 | o3.w = o2; 6 | 7 | //declare var exports: { w: any }; 8 | 9 | module.exports = o3; 10 | -------------------------------------------------------------------------------- /tests/regexp/regexp.exp: -------------------------------------------------------------------------------- 1 | 2 | regexp.js:2:20,44: call of method test 3 | Error: 4 | regexp.js:2:20,44: boolean 5 | This type is incompatible with 6 | regexp.js:2:11,16: number 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/seal/obj_annot.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(param: { name: string; }): number { 4 | return param.id; 5 | } 6 | 7 | foo({ name: "test" }); 8 | 9 | module.exports = foo; 10 | -------------------------------------------------------------------------------- /tests/type-at-pos/type-at-pos.exp: -------------------------------------------------------------------------------- 1 | {"type":"number","reasons":[{"desc":"number","path":"import.js","line":2,"endline":2,"start":11,"end":12}],"path":"test.js","line":5,"endline":5,"start":1,"end":3} 2 | -------------------------------------------------------------------------------- /tests/union/issue-326.js: -------------------------------------------------------------------------------- 1 | var numberAndStringArr:Array = [1,2]; 2 | var stringArr:Array = ['a','b']; 3 | 4 | var result = numberAndStringArr.concat(stringArr); // no error 5 | -------------------------------------------------------------------------------- /tests/getters_and_setters_disabled/getters_and_setters.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | var f = { 6 | get a() { return 4; }, 7 | set b(x: number) { this.c = b; }, 8 | c: 10, 9 | }; 10 | -------------------------------------------------------------------------------- /tests/intersection/intersection.js: -------------------------------------------------------------------------------- 1 | function foo(x: $All): number { 2 | return x.type; 3 | } 4 | 5 | function bar(x: Error & {type:number}): number { 6 | return x.type; 7 | } 8 | -------------------------------------------------------------------------------- /tests/liberr/libs/parse_error.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | declare class ExampleClass { 5 | 6 | methodA: () => any // parse error, missing comma 7 | 8 | methodB: () => any 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/object_is/object_is.exp: -------------------------------------------------------------------------------- 1 | 2 | object_is.js:20:17,35: Object.is 3 | Error: 4 | object_is.js:20:17,35: boolean 5 | This type is incompatible with 6 | object_is.js:20:8,13: string 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/optional/optional_param2.js: -------------------------------------------------------------------------------- 1 | declare class I { 2 | map( 3 | mapper: (value?: V) => M 4 | ): I; 5 | } 6 | var i:I = new I(); 7 | var j:I = i.map(id => id); 8 | -------------------------------------------------------------------------------- /tests/statics/class_statics.js: -------------------------------------------------------------------------------- 1 | class C { 2 | static f(x:number) { } 3 | static x:string; 4 | } 5 | 6 | C.g = function(x:string) { C.f(x); }; 7 | C.g(0); 8 | 9 | var x:number = C.x; 10 | C.x = 0; -------------------------------------------------------------------------------- /tests/async/await_not_in_async2.js: -------------------------------------------------------------------------------- 1 | // note: currently, await-within-async enforcement is a 2 | // done by the parser, which bails after a single error. 3 | 4 | function f(x) { return x; } 5 | 6 | f(await 1); 7 | -------------------------------------------------------------------------------- /tests/declare_class/lib/test.js: -------------------------------------------------------------------------------- 1 | declare class _C { 2 | foo(): number; 3 | } 4 | declare var _module: { 5 | C: Class<_C>; 6 | } 7 | declare class D extends _module.C { 8 | foo(): string; 9 | } 10 | -------------------------------------------------------------------------------- /tests/docblock/docblock.exp: -------------------------------------------------------------------------------- 1 | 2 | docblock.js:34:1,3: assignment of property o 3 | Error: 4 | docblock.js:34:3,3: property o 5 | Property not found in 6 | docblock.js:18:7,7: statics of C 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/immutable_methods/immutable_methods.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:9:1,5: assignment of property foo 3 | Error: 4 | test.js:9:3,5: property foo 5 | Property not found in 6 | test.js:1:7,7: A 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/lib/libtest.js: -------------------------------------------------------------------------------- 1 | var x:string = NaN 2 | var y:string = Number.MAX_VALUE; 3 | var z:number = new TypeError().name; 4 | var w:string = parseInt("..."); 5 | 6 | var a = new Map(); 7 | a.delete('foobar'); 8 | -------------------------------------------------------------------------------- /tests/misc/E.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule E */ 3 | 4 | function h(x:number) { } 5 | var proto = { fn: h } 6 | 7 | var o = Object.create(proto); 8 | o.fn(false); 9 | 10 | module.exports = {obj: o}; 11 | -------------------------------------------------------------------------------- /tests/overload/test2.js: -------------------------------------------------------------------------------- 1 | declare class Foo { 2 | bar(x: 'hmm'): number; 3 | bar(x: string): string; 4 | } 5 | var foo = new Foo; 6 | (foo.bar('hmm'): number); // OK 7 | (foo.bar('hmmm'): number); // error 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *TAGS 2 | _build 3 | .DS_STORE 4 | docs/_site/ 5 | bin 6 | npm-debug.log 7 | *.diff 8 | *.err 9 | 10 | # ignore files generated by src/dts/runtests.sh 11 | src/dts/tests/*/declarations/*.js 12 | -------------------------------------------------------------------------------- /src/dts/tests/classes/classes.exp: -------------------------------------------------------------------------------- 1 | 2 | classes.js: inconsistent use of library definitions 3 | [LIB] classes.js:1:1,3:1: C 4 | This type is incompatible with 5 | [LIB] classes.js:4:1,6:1: D 6 | 7 | Found 1 error 8 | -------------------------------------------------------------------------------- /src/dts/tests/enums/declarations/enums.js.exp: -------------------------------------------------------------------------------- 1 | // This was originally an Enum. See line 1 in .d.ts file. 2 | declare class Color { 3 | static R : number; 4 | static G : number; 5 | static B : number; 6 | } 7 | -------------------------------------------------------------------------------- /src/dts/tests/modules2/declarations/modules2.js.exp: -------------------------------------------------------------------------------- 1 | // Module declared on line 1 in .d.ts file 2 | declare module "M.N" { 3 | declare var x: number; 4 | declare class C { 5 | y: typeof x; 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/dts/tests/type_alias/declarations/type_alias.js.exp: -------------------------------------------------------------------------------- 1 | // Module declared on line 1 in .d.ts file 2 | declare module "M" { 3 | declare type NumString = number | string; 4 | declare var x: NumString; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/iterable/string.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var stringTest1: Iterable = "hi"; 4 | var stringTest3: Iterable<*> = "hi"; 5 | var stringTest3: Iterable = "hi"; // Error - string is a Iterable 6 | -------------------------------------------------------------------------------- /tests/more_classes/Qux.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule Qux */ 3 | 4 | class Qux { 5 | w:number; 6 | 7 | qux() { return this.w; } 8 | 9 | fooqux(x:number) { } 10 | } 11 | 12 | module.exports = Qux; 13 | -------------------------------------------------------------------------------- /tests/simple_arrays/array.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | var a = []; 3 | for (var i = 0; i < 10; ++i) { 4 | if (i % 2 == 0) { a[i] = 0; } 5 | else { a[i] = ''; }; 6 | } 7 | 8 | function foo(i): string { return a[i]; } 9 | -------------------------------------------------------------------------------- /tests/strict/obj.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | // progressively annotate: 6 | 7 | var o = { x: 0 } 8 | //var o: {x: number;} = { x: 0 } 9 | 10 | var x:string = o.x; 11 | 12 | module.exports = o; 13 | -------------------------------------------------------------------------------- /src/dts/tests/modules/modules.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var M = require('M');; 3 | 4 | var x : M.C = new M.C(); 5 | var z : typeof M.x = x.y; 6 | var m : string = z; 7 | var obj = new I(); 8 | var ret: string = obj.get_y(x); 9 | -------------------------------------------------------------------------------- /tests/async/await_not_in_async3.js: -------------------------------------------------------------------------------- 1 | // note: currently, await-within-async enforcement is a 2 | // done by the parser, which bails after a single error. 3 | 4 | async function f(x) { return x; } 5 | 6 | f(await 1); 7 | -------------------------------------------------------------------------------- /tests/config_module_name_rewrite_haste/config_module_name_rewrite_haste.exp: -------------------------------------------------------------------------------- 1 | 2 | A.js:12:10,32: Exists3 3 | Required module not found 4 | 5 | A.js:13:22,35: Exists4 6 | Required module not found 7 | 8 | Found 2 errors 9 | -------------------------------------------------------------------------------- /tests/strict/annot.js: -------------------------------------------------------------------------------- 1 | var A = require('./unknown_class'); 2 | 3 | class B extends A { 4 | foo(x:A):A { return x; } 5 | bar(x) { } 6 | qux(x:X,y:Y):X { return x;} 7 | } 8 | 9 | module.exports = B; 10 | -------------------------------------------------------------------------------- /tests/tuples/tuples.js: -------------------------------------------------------------------------------- 1 | var a: [] = []; 2 | var b: [] = [123]; 3 | var c: [number] = []; 4 | var d: [number, string] = [123,'duck']; 5 | var e: [number, string,] = [123,'duck']; 6 | var f: [number, string] = [123, 456]; 7 | -------------------------------------------------------------------------------- /tests/union/fields2.js: -------------------------------------------------------------------------------- 1 | class C { } 2 | 3 | class D { 4 | content: string|C; 5 | copyContent(content: C): string|C { 6 | this.content = content; 7 | return this.content; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dts/tests/interface_var/declarations/interface_var.d.ts: -------------------------------------------------------------------------------- 1 | interface adult { 2 | height: number; 3 | age: number; 4 | } 5 | 6 | declare var adult: { 7 | minage: number; 8 | new(): adult; 9 | } 10 | -------------------------------------------------------------------------------- /src/dts/tests/var_interface/declarations/var_interface.d.ts: -------------------------------------------------------------------------------- 1 | declare var adult: { 2 | minage: number; 3 | new(): adult; 4 | } 5 | 6 | interface adult { 7 | height: number; 8 | age: number; 9 | } 10 | -------------------------------------------------------------------------------- /tests/plsummit/locals.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo() { 4 | var x = 0; 5 | var y = x; 6 | } 7 | 8 | function bar(x: ?string): number { 9 | if (x == null) x = ""; 10 | return x.length; 11 | } 12 | -------------------------------------------------------------------------------- /tests/refinements/ast_node.js: -------------------------------------------------------------------------------- 1 | type Node1 = { 2 | kind: 'Node1', 3 | prop1?: string 4 | }; 5 | 6 | type Node2 = { 7 | kind: 'Node2', 8 | prop2?: string 9 | } 10 | 11 | export type ASTNode = Node1 | Node2; 12 | -------------------------------------------------------------------------------- /tests/suggest/suggest.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var bar = require('./lib'); 4 | 5 | function foo(z: number) { return bar(z); } 6 | 7 | var array = ["foo", "bar"]; 8 | array; 9 | 10 | module.exports = {foo:foo}; 11 | -------------------------------------------------------------------------------- /tests/suppress/suppress.exp: -------------------------------------------------------------------------------- 1 | 2 | A.js:14:1,38: Error suppressing comment 3 | Unused suppression 4 | 5 | A.js:16:21,23: number 6 | This type is incompatible with 7 | A.js:16:12,17: string 8 | 9 | Found 2 errors 10 | -------------------------------------------------------------------------------- /tests/any/any.js: -------------------------------------------------------------------------------- 1 | function foo(x:any):any { return x; } 2 | function bar(x:any):mixed { return x; } 3 | function qux(x:mixed):any { return x; } 4 | 5 | var x:string = foo(0); 6 | var y:string = bar(0); 7 | var z:string = qux(0); 8 | -------------------------------------------------------------------------------- /tests/import_type/ExportNamed_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo2 { 6 | returnsANumber(): number { return 42; } 7 | } 8 | 9 | export {ClassFoo2}; 10 | export var foo2Inst = new ClassFoo2(); 11 | -------------------------------------------------------------------------------- /tests/more_path/FlowSA.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule FlowSA */ 3 | 4 | function check(x:string) { } 5 | 6 | function FlowSA() { 7 | var x = 0; 8 | x = "..."; 9 | check(x); 10 | } 11 | 12 | module.exports = FlowSA; 13 | -------------------------------------------------------------------------------- /examples/03_Null/answer/nulls.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function length(x) { 4 | if (x != null) { 5 | return x.length; 6 | } else { 7 | return 0; 8 | } 9 | } 10 | 11 | var total = length("Hello") + length(null); 12 | -------------------------------------------------------------------------------- /src/dts/tests/enums/enums.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var x = Color.R; 3 | 4 | var y: string = ""; 5 | 6 | switch (x) { 7 | case Color.B: 8 | y = Color.R; 9 | case Color.R: 10 | y = "this is a string"; 11 | } 12 | -------------------------------------------------------------------------------- /tests/equals/equals.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | (1 == 1); 4 | ("foo" == "bar"); 5 | (1 == null); 6 | (null == 1); 7 | (1 == ""); // error 8 | ("" == 1); // error 9 | 10 | var x = (null : ?number); 11 | (x == 1); 12 | (1 == x); 13 | -------------------------------------------------------------------------------- /tests/getters_and_setters_enabled/react.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | React.createClass({ 6 | propTypes: { 7 | get a() { return 4; }, 8 | set b(x: number) { this.c = x; }, 9 | c: 10, 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /tests/import_type/ExportDefault_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo1 { 6 | returnsANumber(): number { return 42; } 7 | } 8 | 9 | export default ClassFoo1; 10 | export var foo1Inst = new ClassFoo1(); 11 | -------------------------------------------------------------------------------- /tests/suppress/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | lib.js 7 | 8 | [options] 9 | suppress_comment=.*\\$FlowFixMe 10 | suppress_comment=.*\\$FlowIssue 11 | suppress_comment=\\(.\\|\n\\)*\\$FlowNewLine 12 | -------------------------------------------------------------------------------- /examples/02_TypeAnnotations/answer/type_annotations.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | // Changing the return type to number fixes the error 4 | function foo(x: string, y: number): number { 5 | return x.length * y; 6 | } 7 | 8 | foo("Hello", 42); 9 | -------------------------------------------------------------------------------- /tests/class_property_initializers/class_property_initializers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class A { 6 | thisIsSupported: string; 7 | thisIsNotSupportedYet = 123; 8 | thisIsNotSupportedYetEither: number = 123; 9 | } 10 | -------------------------------------------------------------------------------- /tests/mixins/mixins.exp: -------------------------------------------------------------------------------- 1 | 2 | Bar.js:1:16,16: number 3 | This type is incompatible with 4 | test.js:5:12,17: string 5 | 6 | test.js:6:10,10: property y 7 | Property not found in 8 | test.js:3:7,9: Foo 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/undefined/undefined.js: -------------------------------------------------------------------------------- 1 | function foo() { 2 | var x; 3 | x.foo(); 4 | } 5 | 6 | function bar() { 7 | var x:?{ bar():void; }; 8 | if (x) x.bar(); 9 | } 10 | 11 | function qux(x?: number, y:string = "", z) { } 12 | -------------------------------------------------------------------------------- /tests/unreachable/unreachable.exp: -------------------------------------------------------------------------------- 1 | 2 | unreachable.js:13:13,15:3: 3 | unreachable code 4 | 5 | unreachable.js:22:11,11: 6 | unreachable code 7 | 8 | unreachable.js:24:11,11: 9 | unreachable code 10 | 11 | Found 3 errors 12 | -------------------------------------------------------------------------------- /examples/05_DynamicCode/answer/dynamic.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(x) { 4 | if (typeof x === 'string') { 5 | return x.length; 6 | } else { 7 | return x; 8 | } 9 | } 10 | 11 | var res = foo("Hello") + foo(42); 12 | -------------------------------------------------------------------------------- /src/dts/tests/export_modules/export_modules.exp: -------------------------------------------------------------------------------- 1 | 2 | export_modules.js:3:19,30: property y 3 | Error: 4 | export_modules.js:3:9,14: string 5 | This type is incompatible with 6 | [LIB] export_modules.js:18:18,23: number 7 | 8 | Found 1 error 9 | -------------------------------------------------------------------------------- /tests/get-def/library.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { 4 | 5 | iTakeAString: function(name: string): number { 6 | return 42; 7 | }, 8 | 9 | bar: function(): number { 10 | return 42; 11 | }, 12 | 13 | }; 14 | -------------------------------------------------------------------------------- /tests/misc/C.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule C */ 3 | 4 | var B = require('B'); 5 | var f = require('A').fn; 6 | 7 | function C() { 8 | var o = new B(); 9 | f(o.b); 10 | f(o.s); 11 | o.fn(); 12 | } 13 | 14 | module.exports = C; 15 | -------------------------------------------------------------------------------- /tests/react/import_react.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | import react from "react"; 4 | import {Component} from "react"; 5 | 6 | var a: Component = new react.Component(); 7 | var b: number = new react.Component(); // Error: ReactComponent ~> number 8 | -------------------------------------------------------------------------------- /tests/declare_type/lib/DeclareModule_TypeAlias.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | declare module ModuleAliasFoo { 6 | declare type baz = number; 7 | declare type toz = string; 8 | declare function foo(bar : baz) : toz; 9 | } 10 | -------------------------------------------------------------------------------- /tests/destructuring/destructuring_param.js: -------------------------------------------------------------------------------- 1 | function f(a, { b }) { 2 | return a + b; 3 | } 4 | 5 | function g(a, { a }) { 6 | return a; 7 | } 8 | 9 | function h({ a, { b } }, { c }, { { d } }) { 10 | return a + b + c + d; 11 | } 12 | -------------------------------------------------------------------------------- /tests/iterable/iter.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(strs: Iterable): void { 4 | for (var s: string of strs) { 5 | console.log(s); 6 | } 7 | } 8 | 9 | var m: Map = new Map(); 10 | 11 | foo(m.keys()); 12 | -------------------------------------------------------------------------------- /tests/modules/lib.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function g(x:string) { } 4 | 5 | //function f(x) { g(x); return x; } 6 | //function f(x:number) { g(x); return x; } 7 | function f(x:number):number { g(x); return x; } 8 | 9 | module.exports = f; 10 | -------------------------------------------------------------------------------- /tests/more_statics/class_static.js: -------------------------------------------------------------------------------- 1 | class B { 2 | static foo(): string { return ""; } 3 | } 4 | 5 | class C extends B { 6 | static bar(): string { return ""; } 7 | } 8 | 9 | var x: number = C.bar(); 10 | var y: number = C.foo(); 11 | -------------------------------------------------------------------------------- /tests/value/value.exp: -------------------------------------------------------------------------------- 1 | 2 | value.js:2:10,10: number 3 | This type is incompatible with 4 | value.js:3:7,12: string 5 | 6 | value.js:6:14,20: string 7 | This type is incompatible with 8 | value.js:5:27,32: number 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you have any questions, please drop us a line at cla@fb.com. Thanks! 2 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportFrom_Intermediary1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportFrom_Intermediary1 3 | * @flow 4 | */ 5 | 6 | export { 7 | numberValue1, 8 | numberValue2 as numberValue2_renamed 9 | } from "ES6_ExportFrom_Source1"; 10 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_ExportFrom_Intermediary2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_ExportFrom_Intermediary2 3 | * @flow 4 | */ 5 | 6 | export { 7 | numberValue1, 8 | numberValue2 as numberValue2_renamed2 9 | } from "ES6_ExportFrom_Source2"; 10 | -------------------------------------------------------------------------------- /tests/getters_and_setters_disabled/getters_and_setters_disabled.exp: -------------------------------------------------------------------------------- 1 | 2 | getters_and_setters.js:6:3,23: 3 | get/set properties not yet supported 4 | 5 | getters_and_setters.js:7:3,34: 6 | get/set properties not yet supported 7 | 8 | Found 2 errors 9 | -------------------------------------------------------------------------------- /tests/immutable_methods/test.js: -------------------------------------------------------------------------------- 1 | class A { 2 | foo(): A { return this; } 3 | } 4 | class B extends A { 5 | foo(): B { return this; } 6 | } 7 | class C extends A {} 8 | var a: A = new B(); 9 | a.foo = function(): C { return new C(); } 10 | -------------------------------------------------------------------------------- /tests/sealed/function.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function Bar(x: number) { 4 | this.x = x; 5 | } 6 | Bar.prototype.getX = function() { return this.x; } 7 | Bar.prototype.getY = function(): string { return this.y; } 8 | 9 | module.exports = Bar; 10 | -------------------------------------------------------------------------------- /src/dts/tests/modules/declarations/modules.d.ts: -------------------------------------------------------------------------------- 1 | declare module M { 2 | export var x: number 3 | export class C { 4 | y : typeof x 5 | } 6 | } 7 | 8 | interface I { 9 | x : typeof M.x 10 | get_y(c: M.C): typeof M.x 11 | } 12 | -------------------------------------------------------------------------------- /tests/class_type/test.js: -------------------------------------------------------------------------------- 1 | class A { } 2 | function foo(x: Class): A { 3 | return new x(); // OK 4 | } 5 | 6 | class B { 7 | constructor(_: any) { } 8 | } 9 | function bar(x: Class): B { 10 | return new x(); // error (too few args) 11 | } 12 | -------------------------------------------------------------------------------- /tests/closure/closure.exp: -------------------------------------------------------------------------------- 1 | 2 | Closure.js:11:5,6: number 3 | This type is incompatible with 4 | Closure.js:4:22,27: string 5 | 6 | Closure.js:32:5,6: number 7 | This type is incompatible with 8 | Closure.js:4:22,27: string 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/es6modules/ProvidesModuleA.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule A 3 | * @flow 4 | */ 5 | 6 | exports.numberValue1 = 42; 7 | exports.numberValue2 = 42; 8 | exports.numberValue3 = 42; 9 | exports.numberValue4 = 42; 10 | exports.stringValue = "str"; 11 | -------------------------------------------------------------------------------- /tests/issues-11/issues-11.exp: -------------------------------------------------------------------------------- 1 | 2 | export.js:2:13,13: number 3 | This type is incompatible with 4 | import.js:3:8,13: string 5 | 6 | export.js:3:13,14: string 7 | This type is incompatible with 8 | import.js:4:8,13: number 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/while/test.js: -------------------------------------------------------------------------------- 1 | class C { 2 | m() { return new C; } 3 | } 4 | function blah() {} 5 | var node: ?C = new C; 6 | while (node) { 7 | var parent = node.m(); 8 | var cloneable: C = node; 9 | blah(); 10 | node = parent.m(); 11 | } 12 | -------------------------------------------------------------------------------- /hack/third-party/core/poly.ml: -------------------------------------------------------------------------------- 1 | (** [Poly] is a convenient shorthand for [Polymorphic_compare] in the common case that one 2 | wants to use a polymorphic comparator directly in an expression, e.g. [Poly.equal a 3 | b]. *) 4 | 5 | include Polymorphic_compare 6 | -------------------------------------------------------------------------------- /tests/autocomplete_json/autocomplete_json.exp: -------------------------------------------------------------------------------- 1 | [{"name":"num","type":"number","func_details":null,"path":"foo.js","line":6,"endline":6,"start":8,"end":10},{"name":"str","type":"string","func_details":null,"path":"foo.js","line":7,"endline":7,"start":8,"end":14}] 2 | -------------------------------------------------------------------------------- /tests/es6modules/CommonJS_Named.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule CommonJS_Named 3 | * @flow 4 | */ 5 | 6 | exports.numberValue1 = 1; 7 | exports.numberValue2 = 2; 8 | exports.numberValue3 = 3; 9 | exports.numberValue4 = 4; 10 | exports.numberValue5 = 5; 11 | -------------------------------------------------------------------------------- /tests/object_annot/test.js: -------------------------------------------------------------------------------- 1 | function foo(x: Array): Array { 2 | return x.sort((a, b) => a.foo - b.foo); 3 | } 4 | 5 | // Make sure Object works with Object.keys() 6 | function bar(x: Object): Array { 7 | return Object.keys(x); 8 | } 9 | -------------------------------------------------------------------------------- /tests/error_messages/error_messages.exp: -------------------------------------------------------------------------------- 1 | 2 | errors.js:1:12,17: identifier define 3 | Could not resolve name 4 | 5 | errors.js:3:1,9: function call 6 | Callable signature not found in 7 | [LIB] core.js:27:1,49:1: statics of Object 8 | 9 | Found 2 errors 10 | -------------------------------------------------------------------------------- /tests/import_type/ExportNamed_Alias.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | export type AliasFoo3 = { 6 | givesANum(): number 7 | }; 8 | export function givesAFoo3Obj(): AliasFoo3 { 9 | return { 10 | givesANum(): number { return 42; } 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /tests/misc/D.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule D */ 3 | 4 | var f = require('A').fn; 5 | 6 | function g():string { return this.i; } 7 | 8 | var o = {fn: g, ...{}}; 9 | o.i = true; 10 | 11 | var i = o.fn(); 12 | f(i); 13 | 14 | module.exports = "D for dummy"; 15 | -------------------------------------------------------------------------------- /tests/object_api/object_assign.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var export_ = Object.assign({}, { 4 | foo: function(param) { return param; } 5 | }); 6 | 7 | var decl_export_: { foo: any; bar: any } = Object.assign({}, export_); 8 | 9 | module.exports = export_; 10 | -------------------------------------------------------------------------------- /examples/04_Arrays/arrays.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function total(numbers: Array) { 4 | var result = 0; 5 | for (var i = 0; i < numbers.length; i++) { 6 | result += numbers[i]; 7 | } 8 | return result; 9 | } 10 | 11 | total([1, 2, 3, "Hello"]); 12 | -------------------------------------------------------------------------------- /tests/builtins/genericfoo.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | x:T; 3 | self():Foo { return this; } 4 | map(callbackfn: () => U): Foo { return new Foo(); } 5 | set(x:T): void { } 6 | get(): T { return this.x; } 7 | } 8 | 9 | module.exports = Foo; 10 | -------------------------------------------------------------------------------- /tests/declare_fun/test.js: -------------------------------------------------------------------------------- 1 | declare function foo(x: number): string; 2 | declare function foo(x: string): number; 3 | declare function foo(x: X): X; 4 | 5 | (foo(0): string); // OK 6 | (foo("hello"): number); // OK 7 | (foo(false): void); // error, boolean ~/~ undefined 8 | -------------------------------------------------------------------------------- /tests/export_default/test.js: -------------------------------------------------------------------------------- 1 | var M = require('M'); 2 | var N = require('N'); 3 | N.x = M(N.x); 4 | var P = require('./P'); // implementation of P redirects to module M 5 | N.y = P(N.y); 6 | var Q = require('Q'); // declaration of Q redirects to module M 7 | N.z = Q(N.z); 8 | -------------------------------------------------------------------------------- /tests/import_type/ExportCJSDefault_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo3 { 6 | givesANum(): number { return 42; } 7 | static givesAFoo3(): ClassFoo3 { 8 | return new ClassFoo3(); 9 | } 10 | } 11 | 12 | module.exports = ClassFoo3; 13 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportCJSDefault_Class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | class ClassFoo3 { 6 | givesANum(): number { return 42; } 7 | static givesAFoo3(): ClassFoo3 { 8 | return new ClassFoo3(); 9 | } 10 | } 11 | 12 | module.exports = ClassFoo3; 13 | -------------------------------------------------------------------------------- /tests/import_typeof/ExportNamed_Alias.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | export type AliasFoo3 = { 6 | givesANum(): number 7 | }; 8 | export function givesAFoo3Obj(): AliasFoo3 { 9 | return { 10 | givesANum(): number { return 42; } 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /tests/loners/loners.js: -------------------------------------------------------------------------------- 1 | var o = { x: 5, y: "jello" }; 2 | var z = o.z; 3 | var export_o: { x: number; } = o; 4 | 5 | function f(u,v?):number { return u; } 6 | var export_f: (u: number) => number = f; 7 | 8 | //exports = export_o; 9 | module.exports = export_f; 10 | -------------------------------------------------------------------------------- /examples/04_Arrays/answer/arrays.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function total(numbers: Array) { 4 | var result = 0; 5 | for (var i = 0; i < numbers.length; i++) { 6 | result += numbers[i]; 7 | } 8 | return result; 9 | } 10 | 11 | total([1, 2, 3, 4]); 12 | -------------------------------------------------------------------------------- /tests/class_subtyping/test4.js: -------------------------------------------------------------------------------- 1 | class C { x: X; } 2 | 3 | function foo(c: C, x: X) { } 4 | 5 | type O = { f: number }; 6 | 7 | foo((new C: C), { f_: 0 }); 8 | 9 | class D extends C { 10 | bar() { this.x; } 11 | } 12 | 13 | foo(new D, { f_: 0 }); 14 | -------------------------------------------------------------------------------- /tests/es6modules/CommonJS_Clobbering_Lit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule CommonJS_Clobbering_Lit 3 | * @flow 4 | */ 5 | 6 | module.exports = { 7 | numberValue1: 1, 8 | numberValue2: 2, 9 | numberValue3: 3, 10 | numberValue4: 4, 11 | numberValue5: 5 12 | }; 13 | -------------------------------------------------------------------------------- /tests/interface/interface.exp: -------------------------------------------------------------------------------- 1 | 2 | interface.js:1:22,27: number 3 | This type is incompatible with 4 | interface.js:3:8,13: string 5 | 6 | interface.js:7:13,13: I 7 | type alias referenced from value position 8 | interface.js:5:1,26: type I 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/misc/B.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule B */ 3 | 4 | var A = require('A').cls; 5 | 6 | function B() { 7 | this.b = "..."; 8 | } 9 | 10 | function f():number { return this.b; } 11 | 12 | B.prototype.s = 0; 13 | B.prototype.fn = f; 14 | 15 | module.exports = B; 16 | -------------------------------------------------------------------------------- /tests/optional/optional.js: -------------------------------------------------------------------------------- 1 | function bar(x?,y?) { x * 0; } 2 | bar(0); 3 | 4 | var foo:(x?:number)=>void = bar; 5 | foo(); 6 | 7 | function qux(x="hello",...y):string { foo(x); return y[0]; } 8 | 9 | qux(0,0); 10 | qux(0,...["",42]); 11 | 12 | module.exports = qux; 13 | -------------------------------------------------------------------------------- /tests/strict/fun.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | // progressively annotate: 6 | 7 | //function f(x) { return x; } 8 | function f(x:number) { return x; } 9 | //function f(x:number):string { return x; } 10 | 11 | var x:string = f(0); 12 | 13 | module.exports = f; 14 | -------------------------------------------------------------------------------- /tests/super/super.js: -------------------------------------------------------------------------------- 1 | 2 | class A { 3 | constructor(x:number) { } 4 | f(x:string) { } 5 | } 6 | 7 | class B extends A { 8 | constructor(x:string,y:number) { 9 | super(x); 10 | } 11 | g() { 12 | super.f(0); 13 | return super.g; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/arrows/advanced_arrows.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | var add = (x: number, y: number): number => x + y; 6 | 7 | var bad = (x: number): string => x; // Error! 8 | 9 | var ident = (x: T): T => x; 10 | (ident(1): number); 11 | (ident("hi"): number); // Error 12 | -------------------------------------------------------------------------------- /tests/conditional/conditional.exp: -------------------------------------------------------------------------------- 1 | 2 | conditional.js:22:11,16: number 3 | This type is incompatible with 4 | conditional.js:20:15,20: string 5 | 6 | conditional.js:23:29,37: boolean 7 | This type is incompatible with 8 | conditional.js:20:15,20: string 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/declare_type/declare_type.exp: -------------------------------------------------------------------------------- 1 | 2 | import_declare_type.js:11:15,20: string 3 | This type is incompatible with 4 | [LIB] DeclareModule_TypeAlias.js:6:24,29: number 5 | 6 | import_declare_type.js:12:9,11: identifier toz 7 | Could not resolve name 8 | 9 | Found 2 errors 10 | -------------------------------------------------------------------------------- /tests/type_only_vars/type_alias.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | type Foo = number; 6 | 7 | // You can't use it as an identifier 8 | var x = Foo; 9 | 10 | // But using it in a type should still work 11 | var a: Foo = 123; 12 | var b: Array = [123]; 13 | type c = Foo; 14 | -------------------------------------------------------------------------------- /tests/union/issue-256.js: -------------------------------------------------------------------------------- 1 | declare class Myclass { 2 | myfun(myarray: Array): any; 3 | } 4 | declare var myclass: Myclass; 5 | 6 | myclass.myfun(["1", "2", "3", "4", "5", "6", function (ar) {}]) 7 | myclass.myfun(["1", "2", "3", "4", "5", "6", "7", function (ar) {}]) 8 | -------------------------------------------------------------------------------- /tests/class_property_initializers/class_property_initializers.exp: -------------------------------------------------------------------------------- 1 | 2 | class_property_initializers.js:7:3,30: 3 | class property initializers are not yet supported 4 | 5 | class_property_initializers.js:8:3,44: 6 | class property initializers are not yet supported 7 | 8 | Found 2 errors 9 | -------------------------------------------------------------------------------- /tests/intersection/intersection.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:5:39,42: intersection type 3 | This type is incompatible with 4 | test.js:5:12,35: object type 5 | 6 | test.js:9:43,46: intersection type 7 | This type is incompatible with 8 | test.js:9:12,39: function type 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/more_statics/more_statics.exp: -------------------------------------------------------------------------------- 1 | 2 | class_static.js:9:17,23: string 3 | This type is incompatible with 4 | class_static.js:9:8,13: number 5 | 6 | class_static.js:10:17,23: string 7 | This type is incompatible with 8 | class_static.js:10:8,13: number 9 | 10 | Found 2 errors 11 | -------------------------------------------------------------------------------- /tests/weakmode/should_fail_without_weak.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | // This should fail without weak mode, because of the glaring type error. 3 | 4 | function returns_a_string() { 5 | return "Hello"; 6 | } 7 | 8 | function expects_an_int() { 9 | return returns_a_string() * 10; 10 | } 11 | -------------------------------------------------------------------------------- /tests/weakmode/should_pass_with_weak.js: -------------------------------------------------------------------------------- 1 | /* @flow weak */ 2 | // This should fail without weak mode, because of the glaring type error. 3 | 4 | function returns_a_string() { 5 | return "Hello"; 6 | } 7 | 8 | function expects_an_int() { 9 | return returns_a_string() * 10; 10 | } 11 | -------------------------------------------------------------------------------- /tests/misc/A.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule A */ 3 | 4 | module.exports = {}; 5 | 6 | var A = {x:true, ...{}}; 7 | module.exports.cls = A; 8 | 9 | function f(x:boolean) { } 10 | module.exports.fn = f; 11 | 12 | A.y = "?"; 13 | A.x = A.y; 14 | f(A.x); // A.x is now a string, by def assign 15 | -------------------------------------------------------------------------------- /tests/class_subtyping/test3.js: -------------------------------------------------------------------------------- 1 | class A {} 2 | class B extends A {} 3 | class C extends B {} 4 | 5 | var c: C> = new C; // none of the type args matter 6 | var a: A> = c; // the third type arg is incorrect 7 | -------------------------------------------------------------------------------- /tests/more_react/JSX.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule JSX */ 3 | 4 | var React = require('react'); 5 | var App = require('App.react'); 6 | 7 | var app = 8 | // error, y: number but foo expects string in App.react 9 | Some text. 10 | ; 11 | 12 | module.exports = app; 13 | -------------------------------------------------------------------------------- /tests/parse_error_haste/Unimported.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parse errors but not in flow and not imported. 3 | * Should see no parse errors for this file. 4 | * @providesModule Bar 5 | */ 6 | function f(s:string):string { ### // illegal token 7 | return s; 8 | } 9 | 10 | module.exports = { f: f } 11 | -------------------------------------------------------------------------------- /tests/parse_error_node/Client.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Client imports some but not all modules, 3 | * triggering/suppressing parse errors. 4 | * @flow 5 | */ 6 | 7 | // non-flow files should give parse errors if they're imported 8 | var A = require("./Imported"); // non-Flow file @providesModule Foo 9 | -------------------------------------------------------------------------------- /tests/parse_error_node/Unimported.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parse errors but not in flow and not imported. 3 | * Should see no parse errors for this file. 4 | * @providesModule Bar 5 | */ 6 | function f(s:string):string { ### // illegal token 7 | return s; 8 | } 9 | 10 | module.exports = { f: f } 11 | -------------------------------------------------------------------------------- /tests/return_new/test2.js: -------------------------------------------------------------------------------- 1 | declare class D { 2 | constructor(): { x: number }; // OK 3 | y: any; 4 | } 5 | 6 | var d = new D(); 7 | d.x = ""; // error, string ~/~ number (but property x is found) 8 | 9 | (new D: D); // error, new D doesn't have property y 10 | 11 | module.exports = D; 12 | -------------------------------------------------------------------------------- /tests/sealed/sealed.js: -------------------------------------------------------------------------------- 1 | var o = require('./proto'); 2 | 3 | o.z = 0; 4 | var x:string = o.x; 5 | 6 | var Bar = require('./function'); 7 | var a = new Bar(234); 8 | a.x = 123; 9 | a.y = 'abc'; // error, needs to be declared in Bar's constructor 10 | (a.getX(): number); 11 | (a.getY(): string); 12 | -------------------------------------------------------------------------------- /tests/dictionary/test.js: -------------------------------------------------------------------------------- 1 | type Params = {count: number; [name: string]: string}; 2 | type QueryFunction = (params: Params) => string; 3 | 4 | var o: { foo: QueryFunction } = { 5 | foo(params) { 6 | return params.count; // error, number ~/~ string 7 | } 8 | }; 9 | 10 | module.exports = o; 11 | -------------------------------------------------------------------------------- /tests/node_haste/foo/bar/client.js: -------------------------------------------------------------------------------- 1 | var docblock = require('qux/docblock'); 2 | var min = require('d3/min.js'); 3 | var corge = require('qux/corge'); 4 | 5 | // make sure we don't pick up non-header @providesModule 6 | // annotations - see node_modules/qux/docblock.js 7 | var unreachable = require('annotation'); 8 | -------------------------------------------------------------------------------- /tests/parse/parse.exp: -------------------------------------------------------------------------------- 1 | 2 | fail-flow-2.js:4:1,1: Unexpected token . 3 | 4 | fail-flow.js:3:1,1: Unexpected token . 5 | 6 | fail.js:1:1,1: Unexpected token . 7 | 8 | no_parse_error.js:6:13,13: string 9 | This type is incompatible with 10 | no_parse_error.js:6:9,13: number 11 | 12 | Found 4 errors 13 | -------------------------------------------------------------------------------- /tests/react/proptype_oneOf.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var React = require('react'); 4 | var Example = React.createClass({ 5 | propTypes: { 6 | literal: React.PropTypes.oneOf(["foo"]).isRequired 7 | }, 8 | }); 9 | 10 | var ex1 = ; 11 | var ex2 = ; 12 | -------------------------------------------------------------------------------- /tests/export_default/lib/lib.js: -------------------------------------------------------------------------------- 1 | declare module M { 2 | declare function exports(x:string): string; 3 | } 4 | declare module N { 5 | declare var x: number; 6 | declare var y: number; 7 | declare var z: number; 8 | } 9 | declare module Q { 10 | declare var exports: $Exports<'M'>; 11 | } 12 | -------------------------------------------------------------------------------- /tests/parse_error_node/Imported.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parse errors, imported, not in flow, no provides module. 3 | * Should see a parse error in this file, and module 4 | * not found in client. 5 | */ 6 | function f(s:string):string { ### // illegal token 7 | return s; 8 | } 9 | 10 | module.exports = { f: f } 11 | -------------------------------------------------------------------------------- /tests/react/jsx_spread.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var React = require('react'); 4 | var Foo = React.createClass({ 5 | propTypes: { 6 | bar: React.PropTypes.string.isRequired, 7 | }, 8 | }); 9 | 10 | var props = {bar: 42}; 11 | var blah = ; // error bar, number given string expected 12 | -------------------------------------------------------------------------------- /tests/parse_error_haste/NoProvides.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parse errors, imported, not in flow, no provides module. 3 | * Should see a parse error in this file, and module 4 | * not found in client. 5 | */ 6 | function f(s:string):string { ### // illegal token 7 | return s; 8 | } 9 | 10 | module.exports = { f: f } 11 | -------------------------------------------------------------------------------- /tests/parse_error_haste/parse_error_haste.exp: -------------------------------------------------------------------------------- 1 | 2 | Client.js:8:9,22: Foo 3 | Required module not found 4 | 5 | Client.js:9:9,31: NoProvides.js 6 | Required module not found 7 | 8 | NoProvides.js:6:31,31: Unexpected token ILLEGAL 9 | 10 | Provides.js:7:31,31: Unexpected token ILLEGAL 11 | 12 | Found 4 errors 13 | -------------------------------------------------------------------------------- /src/dts/tests/modules2/modules2.exp: -------------------------------------------------------------------------------- 1 | 2 | modules2.js:5:16,18: number 3 | This type is incompatible with 4 | modules2.js:6:9,14: string 5 | 6 | modules2.js:5:22,24: property y 7 | Error: 8 | modules2.js:6:9,14: string 9 | This type is incompatible with 10 | [LIB] modules2.js:3:18,23: number 11 | 12 | Found 2 errors 13 | -------------------------------------------------------------------------------- /tests/more_react/API.react.js: -------------------------------------------------------------------------------- 1 | 2 | var app = require('JSX'); 3 | 4 | app.setProps({y:42}); // error, y:number but foo expects string in App.react 5 | app.setState({z:42}); // error, z:number but foo expects string in App.react 6 | 7 | function bar(x:number) { } 8 | bar(app.props.children); // error, app.props.children: string 9 | -------------------------------------------------------------------------------- /tests/union/issue-198.js: -------------------------------------------------------------------------------- 1 | var p = new Promise(function(resolve, reject) { 2 | resolve(5); 3 | }) 4 | .then(function(num) { 5 | return num.toFixed(); 6 | }) 7 | .then(function(str) { 8 | // This should fail because str is string, not number 9 | return str.toFixed(); 10 | }); 11 | -------------------------------------------------------------------------------- /tests/private/private.js: -------------------------------------------------------------------------------- 1 | class A { 2 | x: number; 3 | _x: string; 4 | __x: number; 5 | constructor() { this.x = 0; this._x = ""; this.__x = 0; } 6 | } 7 | 8 | class B extends A { 9 | foo() { 10 | var x: number = this.x; 11 | var _x: string = this._x; 12 | var __x: number = this.__x; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/modules/modules.exp: -------------------------------------------------------------------------------- 1 | 2 | cli2.js:5:1,8: function call 3 | Error: 4 | cli2.js:5:3,7: string 5 | This type is incompatible with 6 | lib.js:7:14,19: number 7 | 8 | lib.js:7:31,34: function call 9 | Error: 10 | lib.js:7:33,33: number 11 | This type is incompatible with 12 | lib.js:3:14,19: string 13 | 14 | Found 2 errors 15 | -------------------------------------------------------------------------------- /tests/parse_error_haste/Provides.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parse errors, imported, not in flow, provides module. 3 | * Should see a parse error in this file, and module 4 | * not found in client. 5 | * @providesModule Foo 6 | */ 7 | function f(s:string):string { ### // illegal token 8 | return s; 9 | } 10 | 11 | module.exports = { f: f } 12 | -------------------------------------------------------------------------------- /tests/strict_requires/strict_requires.exp: -------------------------------------------------------------------------------- 1 | 2 | B.js:2:25,26: string 3 | This type is incompatible with 4 | D.js:3:8,13: number 5 | 6 | C.js:3:8,21: number 7 | This type is incompatible with 8 | D.js:4:8,13: string 9 | 10 | D.js:5:7,11: boolean 11 | This type is incompatible with 12 | D.js:4:8,13: string 13 | 14 | Found 3 errors 15 | -------------------------------------------------------------------------------- /src/dts/tests/modules/declarations/modules.js.exp: -------------------------------------------------------------------------------- 1 | // Module declared on line 1 in .d.ts file 2 | declare module "M" { 3 | declare var x: number; 4 | declare class C { 5 | y: typeof x; 6 | } 7 | } 8 | declare var G_M: $Exports<'M'>; 9 | declare interface I { 10 | x: typeof G_M.x; 11 | get_y(c: G_M.C): typeof G_M.x; 12 | } 13 | -------------------------------------------------------------------------------- /tests/builtin_uses/builtin_uses.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:1:9,33: Object.freeze 3 | Error: 4 | test.js:2:2,6: number 5 | This type is incompatible with 6 | test.js:2:9,14: string 7 | 8 | test.js:1:9,33: Object.freeze 9 | Error: 10 | test2.js:2:2,6: number 11 | This type is incompatible with 12 | test2.js:2:9,14: string 13 | 14 | Found 2 errors 15 | -------------------------------------------------------------------------------- /tests/get-def/example.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var lib = require('./library'); 4 | 5 | function add(a: number, b: number): number { 6 | return a + b; 7 | } 8 | 9 | var re = /^keynote (talk){2} (lightning){3,5} (talk){2} closing partytime!!!/ 10 | 11 | // t123456 12 | add(lib.iTakeAString(42), 7); 13 | 14 | // D123456 15 | lib.bar(); 16 | -------------------------------------------------------------------------------- /tests/require/E.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | // Local `exports` var is just a ref to module.exports, so mutating the original 4 | // value will affect the exports object but re-binding it makes it useless and 5 | // does not affect the exports value. 6 | module.exports = { 7 | numberValue: 42 8 | }; 9 | 10 | exports = {stringValue: ''}; 11 | -------------------------------------------------------------------------------- /src/parser/test/run_all.sh: -------------------------------------------------------------------------------- 1 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 2 | 3 | node $DIR/run_esprima_tests.js 4 | esprima_exit=$? 5 | node $DIR/run_hardcoded_tests.js 6 | hardcoded_exit=$? 7 | 8 | if [ $esprima_exit -ne 0 ] || [ $hardcoded_exit -ne 0 ] ; then 9 | echo 10 | echo "FAILED: Some tests failed" 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /tests/covariance/covariance.exp: -------------------------------------------------------------------------------- 1 | 2 | test.js:4:8,9: string 3 | This type is incompatible with 4 | test.js:2:24,29: number 5 | 6 | test.js:12:9,9: number 7 | This type is incompatible with 8 | test.js:13:11,16: string 9 | 10 | test.js:12:9,9: number 11 | This type is incompatible with 12 | test.js:14:15,20: string 13 | 14 | Found 3 errors 15 | -------------------------------------------------------------------------------- /tests/locals/locals.js: -------------------------------------------------------------------------------- 1 | var x:string = 0; 2 | var x:number = 1; 3 | 4 | //declare var T: $Type>; 5 | 6 | function foo(p: bool) {} 7 | 8 | function sorry(really: bool) { 9 | if (really) { 10 | var x: number | string = 1337; 11 | } else { 12 | var x: bool = true; 13 | } 14 | foo(x); 15 | } 16 | -------------------------------------------------------------------------------- /tests/module_redirect/module_redirect.exp: -------------------------------------------------------------------------------- 1 | 2 | B.js:6:18,29: module A 3 | This type is incompatible with 4 | D.js:7:11,16: string 5 | 6 | B.js:6:18,29: module A 7 | This type is incompatible with 8 | D.js:8:11,16: string 9 | 10 | D.js:6:20,31: module A 11 | This type is incompatible with 12 | D.js:6:11,16: string 13 | 14 | Found 3 errors 15 | -------------------------------------------------------------------------------- /tests/more_path/test.js: -------------------------------------------------------------------------------- 1 | class BaseClass { 2 | baseProp: string; 3 | } 4 | 5 | class ChildClass extends BaseClass { 6 | childProp: string; 7 | } 8 | 9 | function test(obj: BaseClass): string { 10 | if (obj instanceof ChildClass) { 11 | return obj.childProp_TYPO; // error (obj: ChildClass) 12 | } 13 | return obj.baseProp; 14 | } 15 | -------------------------------------------------------------------------------- /tests/reflection/reflection.exp: -------------------------------------------------------------------------------- 1 | 2 | type.js:2:19,23: string 3 | This type is incompatible with 4 | type.js:1:16,21: number 5 | 6 | type.js:3:19,23: string 7 | This type is incompatible with 8 | type.js:1:16,21: number 9 | 10 | type.js:6:11,15: string 11 | This type is incompatible with 12 | type.js:5:10,15: number 13 | 14 | Found 3 errors 15 | -------------------------------------------------------------------------------- /tests/equals/equals.exp: -------------------------------------------------------------------------------- 1 | 2 | equals.js:7:2,8: non-strict equality comparison 3 | Error: 4 | equals.js:7:2,2: number 5 | Cannot be compared to 6 | equals.js:7:7,8: string 7 | 8 | equals.js:8:2,8: non-strict equality comparison 9 | Error: 10 | equals.js:8:2,3: string 11 | Cannot be compared to 12 | equals.js:8:8,8: number 13 | 14 | Found 2 errors 15 | -------------------------------------------------------------------------------- /tests/structural_subtyping/builtin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | interface IHasLength { 6 | length: number; 7 | } 8 | 9 | var lengthTest1: IHasLength = []; 10 | var lengthTest2: IHasLength = 'hello'; 11 | var lengthTest3: IHasLength = 123; // number doesn't have length 12 | var lengthTest4: IHasLength = true; // bool doesn't have length 13 | -------------------------------------------------------------------------------- /tests/union/issue-325.js: -------------------------------------------------------------------------------- 1 | class Tag { 2 | constructor() { 3 | var a1: Array = []; 4 | var a2: Array = a1; 5 | } 6 | } 7 | 8 | type Node = Tag_ | string; 9 | class Tag_ { 10 | constructor() { 11 | var a1: Array = [new Tag_]; 12 | var a2: Array = a1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/parse_error_haste/Client.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Client imports some but not all modules, 3 | * triggering/suppressing parse errors. 4 | * @flow 5 | */ 6 | 7 | // non-flow files should give parse errors if they're imported 8 | var A = require("Foo"); // non-Flow file @providesModule Foo 9 | var B = require("./NoProvides"); // non-Flow file 10 | -------------------------------------------------------------------------------- /tests/react/ArityError.react.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ArityError.react 3 | */ 4 | var React = require('react'); 5 | var AudienceInsightsContainer = React.createClass({ 6 | renderComponent(AudienceInsights: ReactClass): ReactElement { 7 | return ; 8 | }, 9 | }); 10 | 11 | module.exports = AudienceInsightsContainer; 12 | -------------------------------------------------------------------------------- /tests/sealed/proto.js: -------------------------------------------------------------------------------- 1 | function Foo() { } 2 | var o = new Foo(); 3 | var x:number = o.x; 4 | 5 | Foo.prototype.m = function() { return this.x; } 6 | 7 | var y:number = o.m(); 8 | o.x = "..."; 9 | 10 | Foo.prototype = { m: function() { return false; } } 11 | 12 | var export_o: { x:any; } = o; // awkward type cast 13 | 14 | module.exports = export_o; 15 | -------------------------------------------------------------------------------- /tests/spread/test3.js: -------------------------------------------------------------------------------- 1 | var p = { y: "" }; 2 | var q = { z: "" }; 3 | var o = { 4 | x: 5, 5 | ...p, 6 | ...q, 7 | }; 8 | var y: number = o.y; 9 | var z: number = o.z; 10 | 11 | // test conflicting keys (they get unioned) 12 | var r = { y: 123 }; 13 | var s = { 14 | ...p, 15 | ...r, 16 | }; 17 | var t: boolean = s.y; // error, string or number 18 | -------------------------------------------------------------------------------- /src/dts/tests/nested_modules/nested_modules.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | var M = require('M'); 3 | var P = require('P'); 4 | var F = require('F'); 5 | var T = require('T'); 6 | var a : string = P.a; 7 | var cc = new M.C(); 8 | var x : string = cc.y; 9 | var two : string = F.successor(1); 10 | var alias_two : typeof two = T.identity(two); 11 | var z : string = M.N.z; 12 | -------------------------------------------------------------------------------- /tests/es6modules/ES6_Default_NamedClass1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule ES6_Default_NamedClass1 3 | * @flow 4 | */ 5 | 6 | export default class Foo { givesANum(): number { return 42; }}; 7 | 8 | // Regression test for https://github.com/facebook/flow/issues/511 9 | // 10 | // Default-exported class should also be available in local scope 11 | new Foo(); 12 | -------------------------------------------------------------------------------- /tests/singleton/number.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function highlander(howMany: 1): number { 4 | return howMany; // there can be only one! 5 | } 6 | 7 | highlander(1); 8 | highlander(2); // error 9 | 10 | 11 | type Foo = 1 | 2 12 | 13 | function bar(num: Foo): number { 14 | return num + 1; 15 | } 16 | 17 | bar(1); 18 | bar(2); 19 | bar(3); // error 20 | -------------------------------------------------------------------------------- /hack/third-party/core/polymorphic_compare.ml: -------------------------------------------------------------------------------- 1 | external compare : 'a -> 'a -> int = "%compare" 2 | external ascending : 'a -> 'a -> int = "%compare" 3 | let descending x y = compare y x 4 | 5 | let (<) = (<) 6 | let (<=) = (<=) 7 | let (>) = (>) 8 | let (>=) = (>=) 9 | let (=) = (=) 10 | let (<>) = (<>) 11 | let equal = (=) 12 | let min = min 13 | let max = max 14 | -------------------------------------------------------------------------------- /tests/intersection/test.js: -------------------------------------------------------------------------------- 1 | var a: any; 2 | 3 | var obj1 : { x: number } & { y: string} = a; 4 | // TODO: the following shouldn't be an error 5 | var obj2 : { x: number; y: string } = obj1; 6 | 7 | var fun1: ((_: number) => void) & ((_: string) => void) = a; 8 | // TODO: the following shouldn't be an error 9 | var fun2 : (_: number | string) => void = obj1; 10 | -------------------------------------------------------------------------------- /tests/react/proptype_object.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var React = require('react'); 4 | var Example = React.createClass({ 5 | propTypes: { 6 | object: React.PropTypes.object.isRequired 7 | }, 8 | }); 9 | 10 | var ok_empty = ; 11 | var ok_props = ; 12 | 13 | var fail_mistyped = 14 | -------------------------------------------------------------------------------- /tests/return/return.exp: -------------------------------------------------------------------------------- 1 | 2 | function_return.js:4:17,17: return 3 | Missing annotation 4 | 5 | function_return.js:7:16,21: return undefined 6 | This type is incompatible with 7 | function_return.js:7:16,21: number 8 | 9 | function_return.js:23:3,9: undefined 10 | This type is incompatible with 11 | function_return.js:19:16,21: number 12 | 13 | Found 3 errors 14 | -------------------------------------------------------------------------------- /src/dts/tests/import_commonjs/import_commonjs.exp: -------------------------------------------------------------------------------- 1 | 2 | import_commonjs.js:3:19,30: property y 3 | Error: 4 | import_commonjs.js:3:9,14: string 5 | This type is incompatible with 6 | [LIB] import_commonjs.js:18:18,23: number 7 | 8 | import_commonjs.js:5:8,13: number 9 | This type is incompatible with 10 | [LIB] import_commonjs.js:40:18,20: C 11 | 12 | Found 2 errors 13 | -------------------------------------------------------------------------------- /tests/iterable/array.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var arrayTest1: Iterable = ([1, 2]: Array); 4 | var arrayTest2: Iterable = [1,2,"hi"]; 5 | var arrayTest3: Iterable = [1,2,3]; 6 | 7 | // Error string ~> number 8 | var arrayTest4: Iterable = ["hi"]; 9 | // Error string ~> number 10 | var arrayTest5: Iterable = ["hi", 1]; 11 | -------------------------------------------------------------------------------- /tests/more_classes/Bar.js: -------------------------------------------------------------------------------- 1 | 2 | /* @providesModule Bar */ 3 | 4 | var Qux = require('Qux'); 5 | 6 | class Bar { 7 | y:number; 8 | self:Bar; 9 | constructor(y:number) { 10 | this.y = y; 11 | this.self = this; 12 | } 13 | 14 | bar(z:string,u:string):string { 15 | new Qux().w = "?"; 16 | return z; 17 | } 18 | } 19 | 20 | module.exports = Bar; 21 | -------------------------------------------------------------------------------- /src/parser/tools/Makefile: -------------------------------------------------------------------------------- 1 | TOP=../../../../hphp/hack/src/ 2 | SRC = native_test_files.ml 3 | 4 | INCLUDEDIRS=.. 5 | 6 | LIBS=../parser_flow.cma 7 | 8 | -include $(TOP)/Makefile.common 9 | 10 | all:: native_test_files 11 | 12 | native_test_files: native_test_files.cmx 13 | ocamlopt $(INCLUDES) -o $@ $(LIBS:.cma=.cmxa) $^ 14 | 15 | clean:: 16 | rm -f native_test_files 17 | -------------------------------------------------------------------------------- /tests/optional_props/test.js: -------------------------------------------------------------------------------- 1 | var x: { } = { foo: 0 }; 2 | var y: { foo?: string } = x; // OK in TypeScript, not OK in Flow 3 | 4 | var z: string = y.foo || ""; 5 | 6 | var o = { }; 7 | y = o; // OK; we know that narrowing could not have happened 8 | o.foo = 0; // future widening is constrained 9 | 10 | function bar(config: { foo?: number }) {} 11 | bar({}); 12 | bar({foo: ""}); 13 | -------------------------------------------------------------------------------- /tests/plsummit/objects.js: -------------------------------------------------------------------------------- 1 | function C() { this.x = 0; } 2 | C.prototype.foo = function() { return this.x; } 3 | 4 | var c = new C(); 5 | var x: string = c.foo(); 6 | 7 | function foo() { return this.y; } 8 | function bar() { return this.foo(); } 9 | var o = { y: "", foo: foo, bar: bar }; 10 | var o2 = { y: 0, foo: foo, bar: bar }; 11 | 12 | o.bar(); 13 | var y: number = o2.bar(); 14 | -------------------------------------------------------------------------------- /tests/poly/poly.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | x:T; 3 | constructor(x:T) { this.x = x; } 4 | } 5 | 6 | function bar(foo:Foo,y:S):Foo { return new Foo(y); } 7 | 8 | var P = { 9 | bar: bar 10 | } 11 | 12 | declare var Q: { 13 | bar(foo:Foo,y:S):Foo; 14 | } 15 | 16 | var foo = new Foo(0); 17 | var x:string = foo.x; 18 | var z:Foo = Q.bar(foo,""); 19 | -------------------------------------------------------------------------------- /hack/stubs/debug.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | let dump_ast _ = "" 12 | -------------------------------------------------------------------------------- /hack/third-party/core/core_printf.ml: -------------------------------------------------------------------------------- 1 | include Printf 2 | 3 | (** failwith, invalid_arg, and exit accepting printf's format. *) 4 | 5 | let failwithf fmt = ksprintf (fun s () -> failwith s) fmt 6 | let invalid_argf fmt = ksprintf (fun s () -> invalid_arg s) fmt 7 | let exitf fmt = ksprintf (fun s () -> Printf.eprintf "%s\n%!" s; exit 1) fmt 8 | -------------------------------------------------------------------------------- /tests/new_react/state2.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | var React = require('react'); 4 | 5 | type FooState = { 6 | key: ?Object; 7 | }; 8 | 9 | var Comp = React.createClass({ 10 | getInitialState: function(): FooState { 11 | return { 12 | key: null, // this used to cause a missing annotation error 13 | }; 14 | } 15 | }); 16 | 17 | module.exports = Comp; 18 | -------------------------------------------------------------------------------- /hack/utils/core.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | module List = Core_list 12 | -------------------------------------------------------------------------------- /tests/liberr/liberr.exp: -------------------------------------------------------------------------------- 1 | 2 | [LIB] parse_error.js:8:3,9: Library parse error: 3 | [LIB] parse_error.js:8:3,9: Unexpected identifier 4 | 5 | [LIB] type_error.js:2:34,38: Library type error: 6 | [LIB] type_error.js:2:34,38: 7 | Incorrect number of type parameters (expected 1) 8 | 9 | a.js:5:17,17: number 10 | This type is incompatible with 11 | a.js:5:8,13: string 12 | 13 | Found 3 errors 14 | -------------------------------------------------------------------------------- /tests/poly/annot.js: -------------------------------------------------------------------------------- 1 | class A { } 2 | new A; // OK, implicitly inferred type args 3 | class B extends A { } // OK, same as above 4 | 5 | function foo(b): A { // assuming A 6 | return b ? (new A: A): (new A: A); 7 | } 8 | 9 | function bar(): A<*> { // error, * can't be {} and {x: string} at the same time 10 | return (new A: A<{}>) || (new A: A<{x: string}>); 11 | } 12 | -------------------------------------------------------------------------------- /hack/server/serverMain.mli: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | val start: unit -> unit 12 | -------------------------------------------------------------------------------- /hack/stubs/linting_service.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | let lint _ _ = () 12 | -------------------------------------------------------------------------------- /tests/enumerror/enumerror.exp: -------------------------------------------------------------------------------- 1 | 2 | enumerror.js:10:1,26: function call 3 | Error: 4 | enumerror.js:10:18,24: string literal PAUSE 5 | Property not found in 6 | enumerror.js:3:37,7:1: object type 7 | 8 | enumerror.js:20:1,27: function call 9 | Error: 10 | enumerror.js:20:19,25: string literal PAUSE 11 | Property not found in 12 | enumerror.js:12:16,16:1: object literal 13 | 14 | Found 2 errors 15 | -------------------------------------------------------------------------------- /tests/function/function.exp: -------------------------------------------------------------------------------- 1 | 2 | function.js:29:19,19: function type 3 | This type is incompatible with 4 | function.js:29:10,15: number 5 | 6 | function.js:30:19,19: function type 7 | This type is incompatible with 8 | function.js:30:10,15: string 9 | 10 | function.js:31:21,21: object type 11 | This type is incompatible with 12 | function.js:31:10,17: function type 13 | 14 | Found 3 errors 15 | -------------------------------------------------------------------------------- /tests/iterable/set.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function setTest1(set: Set): Iterable { 4 | return set; 5 | } 6 | function setTest2(set: Set): Iterable { 7 | return set; 8 | }; 9 | function setTest3(set: Set): Iterable { 10 | return set; 11 | } 12 | // Error string ~> number 13 | function setTest4(set: Set): Iterable { 14 | return set; 15 | } 16 | -------------------------------------------------------------------------------- /_tags: -------------------------------------------------------------------------------- 1 | <**/*.ml*>: ocaml, warn_A, warn(-4-6-29-35-44-48-50), warn_error_A 2 | : warn(-3-27) 3 | : warn(-27-34) 4 | : warn(-27-32-34-45) 5 | : warn(-27-32-34-45) 6 | : warn(-27-32-34-45) 7 | : warn(-27-32-34-45) 8 | : warn(-27-32-34-45) 9 | : warn(-27-32-34-45) 10 | -------------------------------------------------------------------------------- /hack/js/hhi.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | let get_hhi_root () = Some "hhi-root" 12 | -------------------------------------------------------------------------------- /hack/stubs/prolog.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | let facts_of_defs _ _ _ _ _ _ = [] 12 | -------------------------------------------------------------------------------- /src/dts/tests/export_modules/declarations/export_modules.d.ts: -------------------------------------------------------------------------------- 1 | declare module "module-P" { 2 | class D { } 3 | declare module P { 4 | export var x: number 5 | export class C { 6 | y : typeof x 7 | } 8 | export var m : typeof N.z 9 | export module N { 10 | export var z : typeof x 11 | } 12 | } 13 | export = P 14 | } 15 | -------------------------------------------------------------------------------- /tests/ignore_package/foo.js: -------------------------------------------------------------------------------- 1 | /** @flow */ 2 | /* this require routes to nothing, because 3 | our node_modules/underscore directory 4 | has been excluded. If package.json files 5 | are being excluded properly, we'll get 6 | 'Required module not found'. 7 | */ 8 | var _ = require('underscore'); 9 | 10 | function foo(): string { 11 | return _.foo(); 12 | } 13 | 14 | module.exports = foo; 15 | -------------------------------------------------------------------------------- /tests/react/proptype_func.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var React = require('react'); 4 | var Example = React.createClass({ 5 | propTypes: { 6 | func: React.PropTypes.func.isRequired 7 | }, 8 | }); 9 | 10 | var ok_void = {}} />; 11 | var ok_args = {}} />; 12 | var ok_retval = 1} /> 13 | 14 | var fail_mistyped = 15 | -------------------------------------------------------------------------------- /tests/try/try.exp: -------------------------------------------------------------------------------- 1 | 2 | return.js:28:3,15: 3 | unreachable code 4 | 5 | return.js:64:3,8: 6 | unreachable code 7 | 8 | test.js:12:5,7: function call 9 | Function cannot be called on 10 | test.js:5:13,14: string 11 | 12 | test.js:13:5,7: function call 13 | Callable signature not found in 14 | test.js:13:5,5: object literal 15 | 16 | test.js:34:5,8: 17 | unreachable code 18 | 19 | Found 5 errors 20 | -------------------------------------------------------------------------------- /tests/while/abnormal.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | function foo(x: boolean) { 4 | var ii = 10; 5 | while (ii-- >= 0) { 6 | if (x) { 7 | continue; 8 | } 9 | return; 10 | } 11 | console.log('this is still reachable'); 12 | } 13 | 14 | function bar(x: boolean) { 15 | var ii = 0; 16 | while (ii > 0) { 17 | return; 18 | } 19 | console.log('this is still reachable'); 20 | } 21 | -------------------------------------------------------------------------------- /hack/typing/typing_alias.mli: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | val get_depth: Nast.stmt -> int 12 | -------------------------------------------------------------------------------- /tests/call_properties/E.js: -------------------------------------------------------------------------------- 1 | // Expecting properties that don't exist should be an error 2 | var a : { someProp: number } = function () {}; 3 | 4 | // Expecting properties that do exist should be fine 5 | var b : { apply: Function } = function () {}; 6 | 7 | // Expecting properties in the functions statics should be fine 8 | var f = function () {}; 9 | f.myProp = 123; 10 | var c : { myProp: number } = f; 11 | -------------------------------------------------------------------------------- /tests/keyvalue/keyvalue.exp: -------------------------------------------------------------------------------- 1 | 2 | keyvalue.js:2:17,25: access of computed property/element 3 | Error: 4 | keyvalue.js:2:8,13: number 5 | This type is incompatible with 6 | [LIB] dom.js:52:22,25: File 7 | 8 | keyvalue.js:2:17,25: access of computed property/element 9 | Error: 10 | keyvalue.js:2:23,24: string 11 | This type is incompatible with 12 | [LIB] dom.js:52:13,18: number 13 | 14 | Found 2 errors 15 | -------------------------------------------------------------------------------- /tests/union/issue-17.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | type T = 4 | {type: "a"; a: number} | 5 | {type: "b"; b: string}; 6 | 7 | var l: Array = [ 8 | {type: "a", a: 1}, 9 | {type: "a", a: 2}, 10 | {type: "a", a: 3}, 11 | {type: "a", a: 4}, 12 | {type: "b", b: "monkey"}, 13 | {type: "b", b: "gorilla"}, 14 | {type: "b", b: "giraffe"}, 15 | {type: "b", b: "penguin"}, 16 | ]; 17 | -------------------------------------------------------------------------------- /src/embedded/flowlib.mli: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | val extract_flowlib : Path.t -> bool 12 | -------------------------------------------------------------------------------- /tests/node_tests/child_process/exec.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | var exec = require('child_process').exec; 4 | 5 | // callback only. 6 | exec('ls', function(error, stdout, stderr) { 7 | console.info(stdout); 8 | }); 9 | 10 | // options only. 11 | exec('ls', {timeout: 250}); 12 | 13 | // options + callback. 14 | exec('ls', {maxBuffer: 100}, function(error, stdout, stderr) { 15 | console.info(stdout); 16 | }); 17 | -------------------------------------------------------------------------------- /tests/demo/2/A.js: -------------------------------------------------------------------------------- 1 | /* @providesModule Demo */ 2 | 3 | class A { 4 | x: number; // instance field declaration 5 | constructor(x) { this.x = x; } 6 | 7 | getX() { return this.x; } 8 | 9 | onLoad(callback) { 10 | return callback(this.getX()); 11 | } 12 | } 13 | 14 | function callback(x: string) { return x.length; } 15 | 16 | var a = new A(42); 17 | a.onLoad(callback); 18 | 19 | module.exports = A; 20 | -------------------------------------------------------------------------------- /tests/new_react/state3.js: -------------------------------------------------------------------------------- 1 | var React = require('react'); 2 | var TestState = React.createClass({ 3 | 4 | getInitialState: function(): { x: string; } { 5 | return { 6 | x: '' 7 | } 8 | }, 9 | 10 | test: function() { 11 | var a: number = this.state.x; // error 12 | 13 | this.setState({ 14 | x: false // error 15 | }) 16 | } 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /tests/throw/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | function f(): number { 6 | throw new Error(); // OK to not return 7 | } 8 | 9 | function g(a: ?string) { 10 | if (a == null) { 11 | throw new Error(); 12 | } 13 | return a*1; // a is not null 14 | } 15 | 16 | function h(x: number): string { 17 | if (x) { 18 | return 'foo'; 19 | } else { 20 | throw new Error(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/type_only_vars/import_type.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @flow 3 | */ 4 | 5 | import type * as A from "./A.js"; 6 | import type {Foo, Bar as Baz} from "./A.js"; 7 | 8 | var actualA = require('./A.js'); 9 | 10 | // You can't use it as an identifier 11 | var m = A; 12 | var n = Foo; 13 | var o = Baz; 14 | 15 | // But using it in a type should still work 16 | var a: Foo = new actualA.Foo(); 17 | (new actualA.Bar(): Baz); 18 | -------------------------------------------------------------------------------- /hack/stubs/prologMain.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | let output_facts _ _ = () 12 | let go _ _ = "" 13 | -------------------------------------------------------------------------------- /tests/refinements/union.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | type thing = number | bool 4 | 5 | function foo(x: thing) { 6 | if (x === true) { 7 | x[0]; // error on boolean 8 | } 9 | } 10 | 11 | function bar(x: thing) { 12 | if (x !== true && x !== false) { 13 | x[0]; // error on number 14 | } 15 | } 16 | 17 | function baz(x: ?thing) { 18 | if (x && x !== true) { 19 | x[0]; // error on number 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hack/stubs/formatEventLogger.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the "hack" directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | *) 10 | 11 | let init _ = () 12 | let patch_choice _ _ _ = () 13 | -------------------------------------------------------------------------------- /tests/arrows/arrows.js: -------------------------------------------------------------------------------- 1 | function selectBestEffortImageForWidth( 2 | maxWidth: number, 3 | images: Array 4 | ): Image { 5 | var maxPixelWidth = maxWidth; 6 | //images = images.sort(function (a, b) { return a.width - b.width }); 7 | images = images.sort((a, b) => (a.width - b.width) + ""); 8 | return images.find(image => image.width >= maxPixelWidth) || 9 | images[images.length - 1]; 10 | } 11 | -------------------------------------------------------------------------------- /tests/ast_tokens/foo.js: -------------------------------------------------------------------------------- 1 | // Regex literals require a lexer mode change 2 | /asdf/g; 3 | 4 | // JSX also requires a lexer mode change 5 |
asdf
; 6 | 7 | // Async arrow functions require backtracking 8 | var a = async () => 42; 9 | 10 | // Type annotations have a special lex mode 11 | var a: number = 42; 12 | 13 | // Token stream should continue even with parse errors 14 | var var 15 | a; 16 | -------------------------------------------------------------------------------- /tests/return_new/test.js: -------------------------------------------------------------------------------- 1 | function Foo() { return {}; } 2 | var foo: number = new Foo(); // error (returns object literal above) 3 | 4 | function Bar() { return 0; } 5 | var bar: number = new Bar(); // error (returns new object) 6 | 7 | function Qux() { } 8 | var qux: number = new Qux(); // error (returns new object) 9 | 10 | class A { } 11 | function B() { return new A(); } 12 | var a: A = new B(); // OK (returns new A) 13 | --------------------------------------------------------------------------------