Giter Club home page Giter Club logo

flowinterfaces's Introduction

Flow Interfaces

Flow interfaces for ~20 npm modules

Usage

Install with NPM

Every interface is available on NPM; each is prefixed with iflow-:

npm install --save-dev iflow-chartist

Add to Flow Config

Add each interface to your .flowconfig:

[libs]
node_modules/iflow-chartist/index.js.flow

Available Interfaces

  • iflow-chartist
  • iflow-core-decorators
  • iflow-invariant
  • iflow-jquery
  • iflow-koa
  • iflow-koa-bodyparser
  • iflow-koa-router
  • iflow-primus-emit
  • iflow-primus-rooms
  • iflow-react-gemini-scrollbar
  • iflow-react-intl
  • iflow-react-native-vector-icons
  • iflow-react-router
  • iflow-react-router-redux
  • iflow-react-widgets
  • iflow-redux-logger
  • iflow-redux-thunk
  • iflow-shallowequal
  • iflow-stardust
  • iflow-vex
  • iflow-warning

Contributing

Pull requests for existing interfaces are welcome. If you plan on adding a new one please contribute to https://github.com/flowtype/flow-typed

flowinterfaces's People

Contributors

amirmikhak avatar autozimu avatar bassettsj avatar bernardop avatar bloojeans avatar chanderson0 avatar chrisbolin avatar darky avatar deminoth avatar flegall avatar glenjamin avatar inv8der avatar kocal avatar luiz290788 avatar m14t avatar marudor avatar masylum avatar moox avatar rmg avatar strml avatar thetechie avatar unknowngalaxy avatar vadzim avatar vojto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flowinterfaces's Issues

Flow 0.33 keeps merging inference forever

Hi! I added the lodash interface, but when running flow (version 0.33) it just keeps on saying [merging inference]. I know this can take some time, but after 2 hours on a 8core machine something is not right...

Do you have an idea how I could debug this?

JQueryXHR class is missing the done, fail and always functions

  1. The jQuery ajax call is defined as ajax(settings: JQueryAjaxSettings): JQueryXHR.

  2. The JQueryXHRtype is defined as:

declare class JQueryXHR {
  overrideMimeType(mimeType: string): any;
  abort(statusText?: string): void;
  then <R> (doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => R, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise <R> ;
  responseJSON?: any;
  error(xhr: JQueryXHR, textStatus: string, errorThrown: string): void;
}
  1. The functions done, fail and always are missing and cause a false positive when used.

iflow-redux has issues when upgrading flow to 0.28.0

I upgraded flow to 0.28.0 and get the following errors for redux interface -

../../node_modules/iflow-redux/index.js.flow:15
 15:     replaceReducer: (reducer: Reducer) => void
                                   ^^^^^^^ Library type error:
 15:     replaceReducer: (reducer: Reducer) => void
                                   ^^^^^^^ Reducer. Application of polymorphic type needs <list of 2 arguments>. (Can use `*` for inferrable ones)

../../node_modules/iflow-redux/index.js.flow:17
 17:   declare type StoreCreator = (reducer: Reducer, initialState: ?State) => Store;
                                             ^^^^^^^ Library type error:
 17:   declare type StoreCreator = (reducer: Reducer, initialState: ?State) => Store;
                                             ^^^^^^^ Reducer. Application of polymorphic type needs <list of 2 arguments>. (Can use `*` for inferrable ones)

../../node_modules/iflow-redux/index.js.flow:20
 20:   declare type Reducers = { [key: string]: Reducer };
                                                ^^^^^^^ Library type error:
 20:   declare type Reducers = { [key: string]: Reducer };
                                                ^^^^^^^ Reducer. Application of polymorphic type needs <list of 2 arguments>. (Can use `*` for inferrable ones)

../../node_modules/iflow-redux/index.js.flow:23
 23:     combineReducers(reducers: Reducers): Reducer;
                                              ^^^^^^^ Library type error:
 23:     combineReducers(reducers: Reducers): Reducer;
                                              ^^^^^^^ Reducer. Application of polymorphic type needs <list of 2 arguments>. (Can use `*` for inferrable ones)

../../node_modules/iflow-redux/index.js.flow:24
 24:     createStore(reducer: Reducer, initialState?: State, enhancer?: StoreEnhancer): Store;
                              ^^^^^^^ Library type error:
 24:     createStore(reducer: Reducer, initialState?: State, enhancer?: StoreEnhancer): Store;
                              ^^^^^^^ Reducer. Application of polymorphic type needs <list of 2 arguments>. (Can use `*` for inferrable ones)

Does the redux interface need to be updated after flow upgrade?

iflow-lodash: zip requires all arrays to be of the same type.

Currently zip is defined as:
zip<T>(...arrays: Array<Array<T>>): NestedArray<T>;
This means all arrays have to be of the same type.
Zip functions are, in my experience, commonly used to mash together arrays of different types.

For example:

const bools: Array<boolean> = [true,true,false];
const ints: Array<number> = [1,2,3];

const zippedArrays = _.zip(ints,bools);

Gives:

----------------
Flow has errors!
----------------

src/components/pages/dashboard/Contexts/Context/UserList/index.js:108
108:     const zippedArrays = _.zip(ints,bools);
                              ^^^^^^^^^^^^^^^^^ call of method `zip`
104:     const bools: Array<boolean> = [true,true,false];
                            ^^^^^^^ boolean. This type is incompatible with
105:     const ints: Array<number> = [1,2,3];
                           ^^^^^^ number

src/components/pages/dashboard/Contexts/Context/UserList/index.js:108
108:     const zippedArrays = _.zip(ints,bools);
                              ^^^^^^^^^^^^^^^^^ call of method `zip`
105:     const ints: Array<number> = [1,2,3];
                           ^^^^^^ number. This type is incompatible with
104:     const bools: Array<boolean> = [true,true,false];
                            ^^^^^^^ boolean

I resolved the errors by redefining zip as:
zip(...arrays: Array<Array<any>>): NestedArray<any>;

The same problem probably holds for many of the other zip-related functions, but i haven't checked them.

JQueryStatic. Ineligible value used in/as type annotation (did you forget 'typeof'?)

Given a line like

toggleStickyFooter: function($stickyFooter: jQuery, fadein: bool = true) {

I get the error JQueryStatic. Ineligible value used in/as type annotation (did you forget 'typeof'?). I'm baffled. I've been trying to modify the definition to fix this for an hour with no luck. Why does it not recognize jQuery as the class for an instance?

JQuery overloads in wrong order!

@marudor, Apparently, Flow requires that the method overloads are ordered from most parameters to least parameters in order for it to choose the correct overload. Otherwise, the overloads are useless, as Flow will always choose the wrong one. See facebook/flow#2891

flow 0.32.0 claims errors on simple jquery.ajaxSetup

$ mkdir interfaces

$ wget -O interfaces/jquery.js.flow https://raw.githubusercontent.com/marudor/flowInterfaces/master/packages/iflow-jquery/index.js.flow

$ flow check-contents < foo.js 
-:2
  2: $.ajaxSetup({
     ^ call of method `ajaxSetup`
  2: $.ajaxSetup({
                 ^ object literal. This type is incompatible with
672:   ajaxSetup(options: JQueryAjaxSettings): void;
                          ^^^^^^^^^^^^^^^^^^ JQueryAjaxSettings. See lib: interfaces/jquery.js.flow:672


Found 1 error

$ cat foo.js 
// @flow -*- indent-tabs-mode: nil; tab-width: 2; js2-basic-offset: 2; coding: utf-8 -*-
$.ajaxSetup({
  url: "ping.php"
});

$ cat .flowconfig 
[ignore]

[include]

[libs]
interfaces/

[options]

$ flow version
Flow, a static type checker for JavaScript, version 0.32.0

Am I missing something obvious here? It seems like this ought to work …

Definitions for jQuery UI or jQuery plugins in general

I'm currently using the jQuery definition file and it works great. Unfortunately I would also need the definitions for the jQuery UI library and several jQuery plugins and I cannot see how to extend the existing definition with other plugins sharing the jQuery namespace?

Partial definitions

Hey!

What are your thoughts on accepting a PR for "partial" definitions for libraries? We have some half-complete flow def files for the methods we use for flot. Would it be helpful?

Preserve elements' type in lodash.flatten

Present flatten declaration removes elements' type information:
flatten(array: any[]): any[];
It's possible to save type information:
flatten<T,X>(array: Array<Array<T>|X>): Array<T|X>;
X is needed because flatten flattens arrays and preserves scalar values like numbers.

Some jQuery methods not chainable without causing incorrect Flow errors

Incorrectly getting Flow error ”Property not found in String“ pertaining to any valid method that is chained after certain chainable jQuery methods, like .attr() and .html().

The following is okay:

/* @flow */

const myDiv: JQuery  = jQuery('#div')

myDiv
  .addClass('someclass')
  .attr('title', 'some title text')

// RESULT: no errors!

But chaining after .attr() shows errors:

/* @flow */

const myDiv: JQuery  = jQuery('#div')

myDiv
  .addClass('someclass')
  .attr('title', 'some title text') // continue chaining…
  .removeClass('someotherclass')

// RESULT: “Flow: 1 error: property `removeClass` Property not found in String

The same occurs with html():

/* @flow */

const myDiv: JQuery  = jQuery('#div')

myDiv
  .addClass('someclass')
  .html('some html content') // continue chaining…
  .text('some content text')

// RESULT: “Flow: 1 error: property `text` Property not found in String

React globals removed in 0.22.0

With the release of 0.22.0 some previously-exposed globals have been removed. This commit facebook/flow@07d737b removed a handful of React globals that allowed interfaces such as the following to work:

declare module 'react-redux' {
  declare interface ConnectedReactClass extends ReactClass {
    static WrappedComponent: ReactClass;
    getWrappedInstance(): ReactComponent; // <----- relevant line
  }
  declare var Provider: ReactClass;
  declare function connect(mapStateToProps?: (state: Object, ownProps?: any) => Object, mapDispatchToProps?: any, mergeProps?: (stateProps: any, dispatchProps: any, ownProps: any) => any, options?: {
    pure?: bool,
    withRef?: bool,
  }): (component: ReactClass) => ConnectedReactClass;
}

It seems as though the correct way to do this now is to import React when it's needed:

import React from 'react' <----- relevant line

declare module 'react-redux' {
  declare interface ConnectedReactClass extends ReactClass {
    static WrappedComponent: ReactClass;
    getWrappedInstance(): React.Component; // <----- relevant line
  }
  declare var Provider: ReactClass;
  declare function connect(mapStateToProps?: (state: Object, ownProps?: any) => Object, mapDispatchToProps?: any, mergeProps?: (stateProps: any, dispatchProps: any, ownProps: any) => any, options?: {
    pure?: bool,
    withRef?: bool,
  }): (component: ReactClass) => ConnectedReactClass;
}

Just as an FYI. Just ran into this so I could be missing something,

Error: Cannot extend multiple classes

I am trying to get running jquery interface but just got error:

../../../node_modules/iflow-jquery/index.js.flow:182
182: declare class JQueryXHR extends XMLHttpRequest, JQueryPromise<any> {
                                     ^^^^^^^^^^^^^^ A class cannot extend multiple classes!

Deps:
"flow-bin": "^0.45.0",
"iflow-jquery": "^1.2.3",

iflow-lodash: _.create declaration appears to be wrong

First off, I am no expert in inheritance, composition, OOP, not by a long way. However, I'm getting a persistent flow error using _.create() as follows:

type A = {
  a: number
}

type B = {
  getA: () => number
}

type Extended = A & B

const obj: A = {
  a: 5
}
const methods: B = {
  getA() {
    return this.a
  }
}

const final: Extended = _.create(methods, obj)

This is an attempted simplification of my case and the error I'm getting is the equivalent of:

call of method `create`. property `a`. Property not found in object type `methods`

The signature of _.create is:

create<T>(prototype: T, properties?: Object): $Supertype<T>

If I change this to the following, no errors are thrown:

create<T>(prototype: T, properties?: Object): $Subtype<T>

Again, I am no expert, but it makes sense to me that the return value of _.create is a subtype of prototype, not a supertype. Am I totally wrong?

[Koa] Moment definitions

node_modules/iflow-koa/index.js.flow:92
 92:     expires?: moment$Moment,
                   ^^^^^^^^^^^^^ identifier `moment$Moment`. Could not resolve name

JQueryPromise doesn't accept arrow function as callback

const response = $.Deferred();

$.when(asyncFindId(99))
  .done((response) => {
    response.resolve(response.length > 0);
  });

This results in:

53:     $.when(asyncFindId(99))
         ^ call of method `done`
 54:       .done((response) => {
                 ^ arrow function. This type is incompatible with
343:   done(doneCallback1?: JQueryPromiseCallback <T> | JQueryPromiseCallback <T> [], ...doneCallbackN: Array < JQueryPromiseCallback <T> | JQueryPromiseCallback <T> [] > ): JQueryPromise <T> ;
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ union: type application of polymorphic type: class type: JQueryPromiseCallback | array type. See lib: node_modules/iflow-jquery/index.js.flow:343

Bluebird type example

First of all, thanks so much for these interfaces, they are truly amazing. But after using a bit of iflow-bluebird, I'm confused on how to type my promises.

I tried:

import Promise from 'bluebird'

const promise: Promise<string> = Promise.resolve('hello')

promise.then(hello => console.log(hello))

…which throws an error:

  6: const promise: Promise<string> = Promise.resolve('hello')
                    ^^^^^^^^^^^^^^^ type application of identifier `Promise`. Expected polymorphic type instead of
  6: const promise: Promise<string> = Promise.resolve('hello')
                    ^^^^^^^^^^^^^^^ class type: BluebirdPromise

So then I tried this:

import Promise from 'bluebird'

const promise: Promise = Promise.resolve('hello')

promise.then(hello => console.log(hello))

…which also didn't work. I believe this is because of this line which wraps BluebirdPromise with Class, is it possible to remove the Class wrapper?

react-redux and flow 0.24.1

Not sure how to deal with this. tried casting ConnectedReactClass to ReactClass but flow didn't allow it.

/* @flow */
import React from 'react';
import { connect } from 'react-redux';

class AClass extends React.Component {
    render() {
        return <span>hello</span>;
    }
}
const Connected = connect()(AClass);

class BClass extends React.Component {
  render() {
    return <Connected />;
  }
}
/*

10: export const Connected = connect()(AClass);
                              ^^^^^^^^^^^^^^^^^ function call
 10: export const Connected = connect()(AClass);
                              ^^^^^^^^^^^^^^^^^ ConnectedReactClass. This type is incompatible with
174:     name: ReactClass<Config> | $Keys<$JSXIntrinsics>,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ union: type application of polymorphic type: type `ReactClass` | key set. See lib: /private/tmp/flow/flowlib_fa82830/react.js:174
  Member 1:
  174:     name: ReactClass<Config> | $Keys<$JSXIntrinsics>,
                 ^^^^^^^^^^^^^^^^^^ type application of polymorphic type: type `ReactClass`. See lib: /private/tmp/flow/flowlib_fa82830/react.js:174
  Error:
   10: export const Connected = connect()(AClass);
                                ^^^^^^^^^^^^^^^^^ ConnectedReactClass. This type is incompatible with
  174:     name: ReactClass<Config> | $Keys<$JSXIntrinsics>,
                 ^^^^^^^^^^^^^^^^^^ class type: existential. See lib: /private/tmp/flow/flowlib_fa82830/react.js:174
  Member 2:
  174:     name: ReactClass<Config> | $Keys<$JSXIntrinsics>,
                                      ^^^^^^^^^^^^^^^^^^^^^ key set. See lib: /private/tmp/flow/flowlib_fa82830/react.js:174
  Error:
   10: export const Connected = connect()(AClass);
                                ^^^^^^^^^^^^^^^^^ ConnectedReactClass. This type is incompatible with
  174:     name: ReactClass<Config> | $Keys<$JSXIntrinsics>,
                                      ^^^^^^^^^^^^^^^^^^^^^ key set. See lib: /private/tmp/flow/flowlib_fa82830/react.js:174
  */

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.