Skip to content

Flow type definition fails with latest flow-bin #1423

@sindresorhus

Description

@sindresorhus

When updating to flow-bin 0.48.0 our type definition test started failing:

> flow check test/flow-types

test/flow-types/regression-1114.js.flow:41
 41: test('2 + 2 === 4', macro, '2 + 2', 4);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150: 	(              run: ContextualTest): void;
151: 	(name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150: 	(              run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   41: test('2 + 2 === 4', macro, '2 + 2', 4);
            ^^^^^^^^^^^^^ string. This type is incompatible with
  150: 	(              run: ContextualTest): void;
       	                    ^^^^^^^^^^^^^^ union: type application of polymorphic type: type `TestFunction` | array type. See: index.js.flow:150
    Member 1:
    100: 	| TestFunction<T, R>
         	  ^^^^^^^^^^^^^^^^^^ type application of polymorphic type: type `TestFunction`. See: index.js.flow:100
    Error:
     41: test('2 + 2 === 4', macro, '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    100: 	| TestFunction<T, R>
         	  ^^^^^^^^^^^^^^^^^^ object type. See: index.js.flow:100
    Member 2:
    101: 	| Array<TestFunction<T, R>>;
         	  ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
    Error:
     41: test('2 + 2 === 4', macro, '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    101: 	| Array<TestFunction<T, R>>;
         	  ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
  Member 2:
  151: 	(name: string, run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   41: test('2 + 2 === 4', macro, '2 + 2', 4);
                                  ^^^^^^^ unused function argument
    151: 	(name: string, run: ContextualTest): void;
         	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 2 arguments. See: index.js.flow:151

test/flow-types/regression-1114.js.flow:42
 42: test(macro, '2 * 3', 6);
     ^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150: 	(              run: ContextualTest): void;
151: 	(name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150: 	(              run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   42: test(macro, '2 * 3', 6);
                   ^^^^^^^ unused function argument
    150: 	(              run: ContextualTest): void;
         	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 1 argument. See: index.js.flow:150
  Member 2:
  151: 	(name: string, run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   42: test(macro, '2 * 3', 6);
            ^^^^^ function. This type is incompatible with the expected param type of
  151: 	(name: string, run: ContextualTest): void;
       	       ^^^^^^ string. See: index.js.flow:151

test/flow-types/regression-1114.js.flow:44
 44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150: 	(              run: ContextualTest): void;
151: 	(name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150: 	(              run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
            ^^^^^^^^^^^^^ string. This type is incompatible with
  150: 	(              run: ContextualTest): void;
       	                    ^^^^^^^^^^^^^^ union: type application of polymorphic type: type `TestFunction` | array type. See: index.js.flow:150
    Member 1:
    100: 	| TestFunction<T, R>
         	  ^^^^^^^^^^^^^^^^^^ type application of polymorphic type: type `TestFunction`. See: index.js.flow:100
    Error:
     44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    100: 	| TestFunction<T, R>
         	  ^^^^^^^^^^^^^^^^^^ object type. See: index.js.flow:100
    Member 2:
    101: 	| Array<TestFunction<T, R>>;
         	  ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
    Error:
     44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    101: 	| Array<TestFunction<T, R>>;
         	  ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
  Member 2:
  151: 	(name: string, run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
                                            ^^^^^^^ unused function argument
    151: 	(name: string, run: ContextualTest): void;
         	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 2 arguments. See: index.js.flow:151

test/flow-types/regression-1114.js.flow:45
 45: test([macro, macro2], '2 * 3', 6);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150: 	(              run: ContextualTest): void;
151: 	(name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150: 	(              run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   45: test([macro, macro2], '2 * 3', 6);
                             ^^^^^^^ unused function argument
    150: 	(              run: ContextualTest): void;
         	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 1 argument. See: index.js.flow:150
  Member 2:
  151: 	(name: string, run: ContextualTest): void;
       	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   45: test([macro, macro2], '2 * 3', 6);
            ^^^^^^^^^^^^^^^ array literal. This type is incompatible with the expected param type of
  151: 	(name: string, run: ContextualTest): void;
       	       ^^^^^^ string. See: index.js.flow:151


Found 4 errors

// @leebyron

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions