Skip to content

Commit

Permalink
Clearer flow type tests with commonjs variant
Browse files Browse the repository at this point in the history
  • Loading branch information
zertosh committed Sep 9, 2018
1 parent 0f54a01 commit bed21a1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
3 changes: 3 additions & 0 deletions __tests__/__fixtures__/flow-package/.flowconfig
@@ -1,5 +1,8 @@
[include]
../../..

[ignore]
.*/node_modules/.*

[version]
0.80.0
11 changes: 11 additions & 0 deletions __tests__/__fixtures__/flow-package/commonjs.js
@@ -0,0 +1,11 @@
/* @flow */

var nullthrows = require('../../..').default;

var obj = ({}: ?Object);

var bad1: Object = obj;
var ok1: Object = nullthrows(obj);

nullthrows(null);
nullthrows(null, 'my error message');
11 changes: 11 additions & 0 deletions __tests__/__fixtures__/flow-package/esmodule.js
@@ -0,0 +1,11 @@
/* @flow */

import nullthrows from '../../..';

var obj = ({}: ?Object);

var bad1: Object = obj;
var ok1: Object = nullthrows(obj);

nullthrows(null);
nullthrows(null, 'my error message');
11 changes: 0 additions & 11 deletions __tests__/__fixtures__/flow-package/index.js

This file was deleted.

39 changes: 28 additions & 11 deletions __tests__/__snapshots__/typechecker-test.js.snap
Expand Up @@ -3,25 +3,42 @@
exports[`nullthrows with flow 1`] = `""`;

exports[`nullthrows with flow 2`] = `
"Error --------------------------------------------------------------- __tests__/__fixtures__/flow-package/index.js:11:20
"Error ------------------------------------------------------------- __tests__/__fixtures__/flow-package/commonjs.js:7:20
Cannot assign \`obj\` to \`bad1\` because null or undefined [1] is incompatible with object type [2].
__tests__/__fixtures__/flow-package/index.js:11:20
11| var bad1: Object = obj;
^^^
__tests__/__fixtures__/flow-package/commonjs.js:7:20
7| var bad1: Object = obj;
^^^
References:
__tests__/__fixtures__/flow-package/index.js:5:16
5| var obj = ({}: ?Object);
^^^^^^^ [1]
__tests__/__fixtures__/flow-package/index.js:11:11
11| var bad1: Object = obj;
^^^^^^ [2]
__tests__/__fixtures__/flow-package/commonjs.js:5:16
5| var obj = ({}: ?Object);
^^^^^^^ [1]
__tests__/__fixtures__/flow-package/commonjs.js:7:11
7| var bad1: Object = obj;
^^^^^^ [2]
Error ------------------------------------------------------------- __tests__/__fixtures__/flow-package/esmodule.js:7:20
Found 1 error
Cannot assign \`obj\` to \`bad1\` because null or undefined [1] is incompatible with object type [2].
__tests__/__fixtures__/flow-package/esmodule.js:7:20
7| var bad1: Object = obj;
^^^
References:
__tests__/__fixtures__/flow-package/esmodule.js:5:16
5| var obj = ({}: ?Object);
^^^^^^^ [1]
__tests__/__fixtures__/flow-package/esmodule.js:7:11
7| var bad1: Object = obj;
^^^^^^ [2]
Found 2 errors
"
`;

Expand Down

0 comments on commit bed21a1

Please sign in to comment.