-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from keyz/master
Improve the Flow type generator
- Loading branch information
Showing
10 changed files
with
2,509 additions
and
1,795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
[ignore] | ||
.*/node_modules | ||
.*/__fixtures__/.* | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[lints] | ||
untyped-import=warn | ||
|
||
[options] | ||
|
||
[strict] | ||
sketchy-null | ||
sketchy-number | ||
untyped-type-import | ||
unclear-type | ||
unsafe-getters-setters | ||
nonstrict-import | ||
unnecessary-optional-chain | ||
unnecessary-invariant | ||
deprecated-utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ignore] | ||
|
||
[include] | ||
../index.js.flow | ||
|
||
[libs] | ||
|
||
[lints] | ||
untyped-import=warn | ||
|
||
[options] | ||
|
||
[strict] | ||
sketchy-null | ||
sketchy-number | ||
untyped-type-import | ||
unclear-type | ||
unsafe-getters-setters | ||
nonstrict-import | ||
unnecessary-optional-chain | ||
unnecessary-invariant | ||
deprecated-utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @flow strict | ||
import * as CSS from '../index.js.flow'; | ||
|
||
const css: CSS.Properties<*> = { | ||
flexGrow: 'invalid', | ||
unknownProperty: 'here', | ||
}; | ||
|
||
const cssWithFallbackValues: CSS.PropertiesFallback<*> = { | ||
flexGrow: [true], | ||
flexDirection: ['123'], | ||
colour: 'typo', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`it detects errors 1`] = ` | ||
"Error ------------------------------------------------------------------------- __fixtures__/flow-errors-fixture.js:4:32 | ||
Cannot assign object literal to \`css\` because: | ||
- property \`unknownProperty\` is missing in \`Properties\` [1] but exists in object literal [2]. | ||
- in property \`flexGrow\`: | ||
- Either string [3] is incompatible with enum [4]. | ||
- Or string [3] is incompatible with number [5]. | ||
__fixtures__/flow-errors-fixture.js:4:32 | ||
v | ||
4| const css: CSS.Properties<*> = { | ||
5| flexGrow: 'invalid', | ||
6| unknownProperty: 'here', | ||
7| }; | ||
^ [2] | ||
References: | ||
__fixtures__/flow-errors-fixture.js:4:12 | ||
4| const css: CSS.Properties<*> = { | ||
^^^^^^^^^^^^^^^^^ [1] | ||
__fixtures__/flow-errors-fixture.js:5:13 | ||
5| flexGrow: 'invalid', | ||
^^^^^^^^^ [3] | ||
index.js.flow:4555:22 | ||
4555| type GlobalsNumber = Globals | number; | ||
^^^^^^^ [4] | ||
index.js.flow:4555:32 | ||
4555| type GlobalsNumber = Globals | number; | ||
^^^^^^ [5] | ||
Error ------------------------------------------------------------------------- __fixtures__/flow-errors-fixture.js:9:58 | ||
Cannot assign object literal to \`cssWithFallbackValues\` because: | ||
- property \`colour\` is missing in \`PropertiesFallback\` [1] but exists in object literal [2]. | ||
- in array element of property \`flexGrow\`: | ||
- Either boolean [3] is incompatible with enum [4]. | ||
- Or boolean [3] is incompatible with number [5]. | ||
- string [6] is incompatible with enum [7] in array element of property \`flexDirection\`. | ||
__fixtures__/flow-errors-fixture.js:9:58 | ||
v | ||
9| const cssWithFallbackValues: CSS.PropertiesFallback<*> = { | ||
10| flexGrow: [true], | ||
11| flexDirection: ['123'], | ||
12| colour: 'typo', | ||
13| }; | ||
^ [2] | ||
References: | ||
__fixtures__/flow-errors-fixture.js:9:30 | ||
9| const cssWithFallbackValues: CSS.PropertiesFallback<*> = { | ||
^^^^^^^^^^^^^^^^^^^^^^^^^ [1] | ||
__fixtures__/flow-errors-fixture.js:10:14 | ||
10| flexGrow: [true], | ||
^^^^ [3] | ||
index.js.flow:4555:22 | ||
4555| type GlobalsNumber = Globals | number; | ||
^^^^^^^ [4] | ||
index.js.flow:4555:32 | ||
4555| type GlobalsNumber = Globals | number; | ||
^^^^^^ [5] | ||
__fixtures__/flow-errors-fixture.js:11:19 | ||
11| flexDirection: ['123'], | ||
^^^^^ [6] | ||
index.js.flow:106:72 | ||
106| type FallbackableFlexDirectionProperty = FlexDirectionProperty | Array<FlexDirectionProperty>; | ||
^^^^^^^^^^^^^^^^^^^^^ [7] | ||
Found 5 errors | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as path from 'path'; | ||
import { spawnSync } from 'child_process'; | ||
|
||
test('it detects errors', () => { | ||
const flowBin = path.resolve( | ||
__dirname, | ||
'../node_modules', | ||
'.bin', | ||
process.platform === 'win32' ? 'flow.cmd' : 'flow', | ||
); | ||
|
||
const fixturesDir = path.resolve(__dirname, '../__fixtures__'); | ||
|
||
const args = ['check', fixturesDir]; | ||
|
||
const result = spawnSync(flowBin, args, { | ||
stdio: 'pipe', | ||
encoding: 'utf8', | ||
}); | ||
|
||
expect(result.stdout).toMatchSnapshot(); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters