Permalink
Commits on Nov 16, 2018
  1. Move `ALoc` module to its own directory

    nmote authored and facebook-github-bot committed Nov 16, 2018
    Reviewed By: gabelevi
    
    Differential Revision: D13090742
    
    fbshipit-source-id: 78bd44b4dd9185088abd536d59fba2862700b7ec
  2. [Normalizer] Do not trigger any more Flow_js evaluation

    panagosg7 authored and facebook-github-bot committed Nov 16, 2018
    Summary:
    The normalizer should not trigger any further Flow_js constraints. This helps keep
    the contexts clean after applying normalization and returns a more faithful perspective
    of the checks that have actually been performed.
    
    This diff removes the two existing invocations under EvalT. This allows for some dead
    code removal. We still query Context.evaluated for EvalTs that have been resolved
    during typechecking.
    
    Reviewed By: pakoito
    
    Differential Revision: D13079187
    
    fbshipit-source-id: 76f25c3bd4c9d05fdaec43f8ba744a278d61f35d
  3. tail recursive list manipulation in error printing

    avikchaudhuri authored and facebook-github-bot committed Nov 16, 2018
    Summary:
    Humungous errors (think 7M+ characters) cause stack overflows / seg faults when pretty
    printing. Using some tail recursive List functions fixes the issue on known examples, but more
    problems might be lurking here and it's hard to change a bunch of inefficient code at once.
    
    Reviewed By: mroch
    
    Differential Revision: D13087128
    
    fbshipit-source-id: afc40299839e4e4b8c78c90aaebae8821d319f03
  4. fix file_sig require processing for generated signature ASTs

    avikchaudhuri authored and facebook-github-bot committed Nov 16, 2018
    Summary:
    Requires and, more generally, other constructs are "normalized" in generated signature ASTs, which
    means that they might be split into elementary parts, which might in turn cause some of the
    corresponding AST nodes to appear multiple times in the AST.
    
    Processing requires in `File_sig` involves a complicated visitor that visits some nodes multiple
    times, and relies on some caching involving the locations of those nodes. Unfortunately when the
    same nodes can appear multiple times, the caching mechanism breaks.
    
    This diff exploits knowledge of the different paths through the visitor that cause multiple visits
    to the same node to fix the caching mechanism.
    
    Reviewed By: panagosg7
    
    Differential Revision: D12972962
    
    fbshipit-source-id: 982f066a15d63f5c842f7de33a431b248c515d34
  5. Disallow trailing comma in function types

    pakoito authored and facebook-github-bot committed Nov 16, 2018
    Summary: This diff fixes an error where a function type would have an additional incorrect trailing comma.
    
    Reviewed By: panagosg7
    
    Differential Revision: D13103593
    
    fbshipit-source-id: 88aaed890f2a4b5276457c097caf6d2111207821
  6. [type-at-pos] Update eval tests

    panagosg7 authored and facebook-github-bot committed Nov 16, 2018
    Summary:
    This change only prepares the type-at-pos tests to avoid noise in the subsequent diff.
    
    The code appended in the end of tests/type-at-pos_types/spread.js ensures that the relevant
    EvalTs are evaluated by Flow's main checking routine. In the next diff, we'll be changing the
    normalizer so that it does not trigger any further constraint generation. So here we're only
    emulating this process, to keep the test as faithful to it's original purpose as possible.
    
    The changes in the beginning of spread.js remove flow errors.
    
    Reviewed By: avikchaudhuri
    
    Differential Revision: D13079194
    
    fbshipit-source-id: 728375fba5fc26c7f18a4e143611451c48e77f04
  7. Flow AST Differ: Add DeclareTypeAlias Statement

    geof90 authored and facebook-github-bot committed Nov 16, 2018
    Summary: Flow AST Differ: Add DeclareTypeAlias Statement
    
    Reviewed By: nmote
    
    Differential Revision: D13088786
    
    fbshipit-source-id: 8dce646dcd47c4a4ad94f2ebfed884e5f41ea00d
  8. fix crash when module ref prefix is used on untyped module

    avikchaudhuri authored and facebook-github-bot committed Nov 15, 2018
    Summary: Loc.none strikes again.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D13056945
    
    fbshipit-source-id: f8bd0f2c8d8f38fca715758d9b20ecd8c43f7f9c
Commits on Nov 15, 2018
  1. [easy] fix stack overflow in ls --json command

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary: List.map was causing stack overflows with `flow ls --json .` This diff uses `rev_map` instead, which gets rid of the error.
    
    Reviewed By: gabelevi
    
    Differential Revision: D13088032
    
    fbshipit-source-id: 51c84c746ac87d6d94c5b95a0d2b8abec027f96d
  2. Convert `Ty` module to use `ALoc`

    nmote authored and facebook-github-bot committed Nov 15, 2018
    Summary: This lets us remove some undesirable `ALoc.to_loc` calls
    
    Reviewed By: panagosg7
    
    Differential Revision: D12994496
    
    fbshipit-source-id: 1b6437870cc2ef7ceb17351bfda3a2928e6bef49
  3. Rename `ty.ml` string utilities to reflect their intent as debugging …

    nmote authored and facebook-github-bot committed Nov 15, 2018
    …tools
    
    Summary: The ones I left alone appear to be used in actual user output. The others appear to be used only for debugging purposes.
    
    Reviewed By: panagosg7
    
    Differential Revision: D12991413
    
    fbshipit-source-id: a68a31990711967958272675f0f6dc52f614c3e8
  4. Remove unnecessary `ALoc.to_loc` calls in `obj_type.ml`

    nmote authored and facebook-github-bot committed Nov 15, 2018
    Reviewed By: dsainati1
    
    Differential Revision: D12990983
    
    fbshipit-source-id: 81e5bd4e3adc8790386ada9a09c0ef53a5df7678
  5. Remove `Loc.btwn` used for decorator warnings

    nmote authored and facebook-github-bot committed Nov 15, 2018
    Summary: Now each decorator is given its own warnings. This seems fine. As a reminder, we need to remove `Loc.btwn` calls in order for abstract locations to work.
    
    Reviewed By: gabelevi
    
    Differential Revision: D12990654
    
    fbshipit-source-id: 61ad709e518368a210b6d9d3cb7c96934a899f4c
  6. use unions to typecheck getkeyst instead of checking each key individ…

    dsainati1 authored and facebook-github-bot committed Nov 15, 2018
    …ually
    
    Summary: rather than flowing each of the keys of an object or instance to the t in GetKeysT(t), create an enum union of these strings and flow that to t, allowing us to make use of our union optimizations to improve performance
    
    Reviewed By: samwgoldman
    
    Differential Revision: D12910949
    
    fbshipit-source-id: 3527143c83cc6dd2adb4e483c0a2f4aa3dac4e19
  7. Better error messages for long string literals being treated as strings

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary:
    String literals with size over a max configurable length are treated as strings. It's helpful to know
    that your string literals are being treated as strings without literal information, as revealed
    by a recent question in our support group.
    
    Reviewed By: gabelevi
    
    Differential Revision: D13044732
    
    fbshipit-source-id: 068852199252302fae1bb699de2c97c8996045d1
  8. [react] rest param in function_component can be None

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary: There's probably no need for a rest param here, but we should make an err diff to confirm.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D13042872
    
    fbshipit-source-id: 10e80a54748e95458c8a0efcd7810cf7f1563f3d
  9. [react] Get rid of polymorphic type aliases in react hooks api

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary:
    Polymorphic type aliases have a known bug where they may cause unnecessary unification. This causes a [problem for the react hooks API types](https://flow.org/try/#0CYUwxgNghgTiAEAXAngBwQISgZwJZgGVEpEQBBMRXAewDsAeAgPngF54AKAtlggSngAfeAQDcAKFCRYCFOngARXNlQkwAC3pkW7Mj3gA3armASp0OEjQIAslGQAjEAGEIIKLQCqqAGK028AD8HBwCrCwAtrgAHiDAfKLw4uIA9CnwAHLUiPAArni0AOZW8lAQuDgg2JLgFggg0ajUMDkAZrm0lDT++SBEJCAAjIxMHOLwE-C4tLhUZf2kAFycofr8QiIANOPwfMsA2gSbK9zhIgLC62dGJgC6EqnpngXFcghlFdhVNdKWDU0teDtTpUOh5L4LEAAJhGY0mUxmcwgkOWITCvAuWx2e3gh2OShUak0WDwhGIpAooIYzCY9x28PEwK6YNI2EQqwA3jswHQ2biAI65EAwZCDY5fRAARSFIshg1uAV6cpCtFyEAgy0CHOErWo1GWqoiThgQgAvnwEjsJdLhchlRzdfr4ABmc0PCY82h8-aC21Q8UgKUyu3k6EK9hK0NQlVqjVBbVAvUG3JG4Vmi0SCbW4OQ6MOpMut3iU1AA).
    
    To get around this, we can get rid of the type aliases until this bug is fixed. The lack of unification made one test have confusing behavior-- I have a comment inline explaining why it errored before and why it requires an explicit type argument to retain its behavior.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D13083694
    
    fbshipit-source-id: 87fc6b37cfaba1d4659d71a3b47ace89ca1b4658
  10. allow less strict flowconfig parsing

    mroch authored and facebook-github-bot committed Nov 15, 2018
    Summary:
    refactors flowconfig parsing to use `result`, and return either the parsed config and a list of warnings, or a single fatal error.
    
    previously, all parsing issues were fatal errors, and directly caused the program to exit. now, unrecognized options are warnings, and things that are always mistakes like invalid syntax or duplicate sections are errors.
    
    warnings are still fatal by default, but the `--ignore-version` flag has been hijacked to also make warnings non-fatal. since warnings currently only include unrecognized options which typically happens when they're from a different version, this makes some sense.
    
    Reviewed By: gabelevi
    
    Differential Revision: D13043219
    
    fbshipit-source-id: 6d254c567666b193f1eef385a648e379cb455755
  11. [react] ReactAbstractComponentT ~> ReactAbstractComponentT

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary:
    Defines the subtyping rules for ReactAbstractComponent<PropsA, DefaultPropsA, InstanceA> <: ReactAbstractComponent<PropsB, DefaultPropsB, InstanceB>
     We check that all of the type arguments unify.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D12964640
    
    fbshipit-source-id: 0397e7273d40254ad87e264d8ff193540f3d8eb9
  12. [react] ClassT ~> AbstractComponentT checking

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary:
    This diff adds the subtyping rule for ClassT <: AbstractComponentT
    
    We check:
    * ClassT's props unifies with AbstractComponentT's props
    * ClassT's defaultProps unifies with AbstractComponentT's defaultProps
    * this <: instance
    
    I'm not 100% certain that the props and defaultProps need to unify. However, [checking for just ClassT's props <: AbstractComponentT's props is unsound](https://flow.org/try/#0PTACDMBsHsHcCgDG0B2BnALgAgEoFMBDRbAXiwCc8BHAVwEtKAKAckqI2YEoBueJSAmjRYAwtAC2AB1R4UGAIJY8ADwyyAJsPzsAdGKky5AHgDe4aNABcWFDXEAjPOQC+APiwnnfEFgCS4LFg8LHVUZmxEAAs8RABrLAxIgmxE4MlyaElhGhQ6cABPABoEyLphTGS8cVlsULw0FHClcgzyHSRUTFFBNXV9aRQa+WttYgASeXtMcnZ+wwxTNywyOcG5eV54HwA5OEDgxAIULAk6bHTM4VgzyOgabCP8rCg9p1a0S3gjER68PokBkMsMBXN5gH4sGgaJJpGhgqlKFgyjZoFgkuRxAlUQRIDBrigAOZKVQzLAXLJYrCOSGSGJ5Oh-QpbcH2e5IjDCFDQFLkGjwpLnDIUgiIwYANycFEI6ipT2QBjWHOKsFKUSRV0i+WZEMSdBQ8TOkNuNEg6ka2GpyDkMzFIroRwwOiwAFloIijjj8mhkWhjaaqcFQoM0U48DogA). More analysis will be done to make sure we're not being overly conservative.
    
    Next, I'll do the subtyping rules for function component <: AbstractComponentT
    
    Reviewed By: samwgoldman
    
    Differential Revision: D12949854
    
    fbshipit-source-id: a1cecc13da344f932b6308abefe59956e7d255a2
  13. [react] Add AbstractComponentT def type

    jbrown215 authored and facebook-github-bot committed Nov 15, 2018
    Summary:
    Adds an internal representation for React$AbstractComponent. This diff adds this new type to all of the places required for Flow to still compile.
    
    I added a test to type-at-pos to make sure normalization is working.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D12943347
    
    fbshipit-source-id: b0c8124665083b7ac6432acc3eae3ffa41a9d14c
  14. Add `catch_body` to baseline mapper

    Peter van der Zee authored and facebook-github-bot committed Nov 15, 2018
    Summary: This adds a `catch_body` method to the Flow_mapper class which will be called when mapping through a `try-catch`.
    
    Reviewed By: arcanis
    
    Differential Revision: D13040144
    
    fbshipit-source-id: b033b781e728cbf30b2bb0777c073e78ec86fca0
  15. Fix bug in Watchman_lwt.close_connection

    gabelevi authored and facebook-github-bot committed Nov 15, 2018
    Summary: There was a bug in `Watchman_lwt` which would cause `EBADF` (error, bad file descriptor) to be thrown when closing a connection via `Watchman_lwt`. Since we never would purposely close a connection, we weren't hitting this.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D13060172
    
    fbshipit-source-id: fc6a75b9cfe6b31b7cd9d2b13b23452366a3dbce
Commits on Nov 14, 2018
  1. fix too-many-files-open error

    avikchaudhuri authored and facebook-github-bot committed Nov 14, 2018
    Reviewed By: panagosg7
    
    Differential Revision: D13044757
    
    fbshipit-source-id: 350b392ee86592f0a8010907e9e3b477dad265fe
  2. Remove weird mixed case from LookupT

    samwgoldman authored and facebook-github-bot committed Nov 14, 2018
    Summary:
    A while back I added a TODO comment asking why we would ever hit MixedT in a
    LookupT failure. I'm finally coming back to figure out why and clean up this
    code.
    
    The lower bound of a LookupT is supposed to be something on the prototype
    chain of an object or an instance, where a GetPropT or SetPropT has already
    failed. Unlike GetPropT/SetPropT, LookupT constraints are not syntax-directed.
    The significance of thise is that NullT as a lower bound of LookupT always
    means a null prototype, rather than a null value.
    
    This also means that a MixedT lower bound is generally unexpected, as a
    prototype chain should only include object-like things and null.
    
    It turns out that this case is only significant in the TestPropT case, which
    forwards all non-null lower bounds to LookupT. This means that the lower bound
    of a LookupT can be mixed. For example, in the program `if (o && o.foo) {}`
    given that `o` is mixed.
    
    It is simpler to handle this case in TestPropT directly, which is what this
    diff does. I have also added a comment explaining why this logic is safe.
    
    Reviewed By: panagosg7
    
    Differential Revision: D13036543
    
    fbshipit-source-id: 9e9f2db5137508958fc0ba262f2bf3221a39958b
Commits on Nov 13, 2018
  1. [type-at-pos] Split tests in multiple folders

    panagosg7 authored and facebook-github-bot committed Nov 13, 2018
    Summary: Enables parallelism dropping the time to run all type-at-pos tests from 1m3s to 30s.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D13033828
    
    fbshipit-source-id: c73b3a7622b3de13a975484ec4b3098833135067
  2. [hack] move opam mini repo in its own subdir

    CatherineGasnier authored and facebook-github-bot committed Nov 13, 2018
    Summary: This is just so that the README make more sense. I had to do that in a separate diff to avoid merge conflict on opam-mini-repo.tar.gz
    
    Reviewed By: vassilmladenov
    
    Differential Revision: D13027425
    
    fbshipit-source-id: 700e1ded451628f70c870390847164c14c98d0bc
  3. [react] reserve React$AbstractComponent

    jbrown215 authored and facebook-github-bot committed Nov 13, 2018
    Summary:
    Adds React$AbstractComponent as a built-in that expects 3 type arguments. I'll be building out the functionality of this type in stacked diffs.
    
    OSS Users: I will follow up with a blog post when we get closer to having this type actually be usable. We expect it to improve the precision and speed with which flow can typecheck React components.
    
    Reviewed By: samwgoldman
    
    Differential Revision: D12925858
    
    fbshipit-source-id: e242dbf74ed2b90eca3fb7f66641bee8b919e530
  4. Change some commandHandler.ml logging from debug to info

    gabelevi authored and facebook-github-bot committed Nov 13, 2018
    Summary: Running a flow server in debug mode will write to the `.log` file each time a command is handled. It would be nice if we did this in non-debug mode too. It makes the log a little more verbose, but is super helpful for debugging.
    
    Reviewed By: jbrown215
    
    Differential Revision: D13004112
    
    fbshipit-source-id: 6a6a365134d420e4357a514997f24def8b33bdcf
  5. [PR] Add React hooks (and tests)

    bvaughn authored and facebook-github-bot committed Nov 13, 2018
    Summary:
    * Added Flow defs for new [React hooks](https://reactjs.org/docs/hooks-intro.html) API along with tests for each new hook.
    * Fixed an error in the `React.createRef` definition. (Refs are for any type of value, not just React elements.)
    * Added missing `calculateChangedBits` param to `React.createContext` definition.
    * Added `React.ConcurrentMode` (16.7+) and tests.
    * Added tests for `React.createRef`, `React.createContext`, and `React.StrictMode` (since they didn't have any coverage previously).
    
    Commits are atomic.
    Pull Request resolved: #7149
    
    Reviewed By: jbrown215
    
    Differential Revision: D12968077
    
    Pulled By: bvaughn
    
    fbshipit-source-id: fa55f4044017f441b5fc67203c067744f4afce23
  6. OSS: build hh with dune

    CatherineGasnier authored and facebook-github-bot committed Nov 13, 2018
    Summary: what the title says.
    
    Reviewed By: vassilmladenov
    
    Differential Revision: D10461407
    
    fbshipit-source-id: 5eda53ea75e3aecf337e598b354a8e7ba8445a9a
  7. [ty_serializer] Fix ReadOnlyArray render

    panagosg7 authored and facebook-github-bot committed Nov 13, 2018
    Summary: Bug fix
    
    Reviewed By: pakoito
    
    Differential Revision: D12990387
    
    fbshipit-source-id: 304d5b137a3184d4d3d11e8e7b123727424d88fe
  8. [annotate-exports] Simplify types after hard-coded fixes

    panagosg7 authored and facebook-github-bot committed Nov 13, 2018
    Summary: Moves `simplify_unions_inters` to ty_utils.ml.
    
    Reviewed By: pakoito
    
    Differential Revision: D12981465
    
    fbshipit-source-id: abd934806bdd07469bf986b15aa2d413b36f2cc7
  9. Remove `events` jsxmin hack from hoister

    pieterv authored and facebook-github-bot committed Nov 13, 2018
    Reviewed By: mroch
    
    Differential Revision: D12983977
    
    fbshipit-source-id: d07a02b131278ca1543147fdfea7444642f6f595
Commits on Nov 12, 2018
  1. [ast-differ] recurse into id and tparams of function_

    a7c authored and facebook-github-bot committed Nov 12, 2018
    Summary: as titled
    
    Reviewed By: nmote
    
    Differential Revision: D12994631
    
    fbshipit-source-id: aab3a06a4bbca182439e0f187d1a0b7fd650c5fa