Git Product home page Git Product logo

Comments (7)

jeffmo avatar jeffmo commented on May 22, 2024 5

Thanks @marudor!

This set of PRs has been really helpful in fleshing out the process of review. Here are some thoughts so far:

Reviewing Test Files

  • Every definition file should have at least one test_ file that exercises it.
  • Each def file should be tested in at least the following ways
    1. Import all declared modules (make sure the act of merely using a libdef doesn't cause flow errors)
    2. Verify that all globals expected to be declared are visible in the test file
    3. Include both positive and negative tests to ensure that type checking is actually happening (AKA: Use // $ExpectError in at least a few places to ensure that we're getting type errors in a few critical places we would expect them)
    4. Include type assertions about at least a few items declared by the definition file (i.e. positive test: (new Widget().install(): void); and negative test: // $ExpectError \n (new Widget().install(): number)

Reviewing Library Definitions

  • I've been looking closely at the docs for the library being defined and comparing that with the libdef
  • In general definitions should avoid using any types (which also includes Function and Object) unless strictly necessary. In many places, using mixed in place of any in definition files will work and is a bit safer because it means that if the type ever leaks out of the definition somehow, it will need to be explicitly refined by the user before it can be used. I've opened #49 to track adding a feature to validate-defs that comments on a PR when it introduces an any type explaining that this should be avoided if at all possible. We don't want to ban any types completely (sometimes they are strictly necessary), only discourage their use if there is an alternative.

I think that's all the patterns/thoughts I've noticed so far, so let's add more here as things progress and eventually put them into the readme!

from flow-typed.

mrmurphy avatar mrmurphy commented on May 22, 2024

Good idea, @chrisbolin. Thanks for posting those!

I'll link another one in here, the immutable.js definitions that are in progress:
immutable-js/immutable-js#203

Specifically, this one by @halletj
immutable-js/immutable-js#203

from flow-typed.

danez avatar danez commented on May 22, 2024

I think it would be also a good idea too move/copy the react definitions from the flow repository itself to here. Although a lot of people probably rely on them currently, so there should be some strategy on how to clever move them without breaking flow for a large group of people. Maybe a deprecation warning if one uses the react definitions from flow itself and how a short message to migrate to this repository.

from flow-typed.

jeffmo avatar jeffmo commented on May 22, 2024

FWIW: I think it would be great to start pulling these libdefs in now.

Most of the remaining work on flow-typed is related to building out the CLI to make it easier to acquire the libdefs -- but seeding the repo (and having a nicely central place for people to come and find them manually) would still be very useful.

from flow-typed.

mrmurphy avatar mrmurphy commented on May 22, 2024

+1, especially @marudor if you have time.

from flow-typed.

marudor avatar marudor commented on May 22, 2024

As you can see by the PRs I've put my libdefs in here. Now it's time to review them.

from flow-typed.

ryyppy avatar ryyppy commented on May 22, 2024

I close this issue, since there is an established process and a list of definitions now :-)

from flow-typed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.