-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flow] Improve error messages on missing props that fail indexer lookups
Summary: If the property name -> indexer type flow does not pass then we do not bother subtyping the value types. This avoids redundant errors. Notably, this can't be done during implicit instantiation because the key/value may contain implicitly instantiated tvars that rely on those flows to constrain them. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D69056970 fbshipit-source-id: f97e5ef69ce326bdd0856c4c714c48917fb40ab4
- Loading branch information
1 parent
7602412
commit 53c63f5
Showing
7 changed files
with
186 additions
and
145 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,21 @@ | ||
Error ---------------------------------------------------------------------------------------------------- test.js:15:23 | ||
Error ---------------------------------------------------------------------------------------------------- test.js:14:23 | ||
|
||
Cannot assign object literal to `error1` because string `foo` [1] is incompatible with string prefixed with `data-` [2] | ||
in the indexer property's key. [incompatible-type] | ||
Cannot assign object literal to `error1` because property `foo` is missing in `Props` [1] but exists in object | ||
literal [2]. Any property that does not exist in `Props` [1] must be compatible with its indexer string prefixed with | ||
`data-` [3]. [incompatible-type] | ||
|
||
test.js:15:23 | ||
15| const error1: Props = {foo: 3}; | ||
^^^^^^^^ [1] | ||
test.js:14:23 | ||
14| const error1: Props = {foo: 3}; // One error | ||
^^^^^^^^ [2] | ||
|
||
References: | ||
test.js:14:15 | ||
14| const error1: Props = {foo: 3}; // One error | ||
^^^^^ [1] | ||
test.js:11:4 | ||
11| [StringPrefix<'data-'>]: string | void, | ||
^^^^^^^^^^^^^^^^^^^^^ [2] | ||
^^^^^^^^^^^^^^^^^^^^^ [3] | ||
|
||
|
||
Error ---------------------------------------------------------------------------------------------------- test.js:15:29 | ||
|
||
Cannot assign object literal to `error1` because in property `foo`: [incompatible-type] | ||
- Either number [1] is incompatible with string [2]. | ||
- Or number [1] is incompatible with undefined [3]. | ||
|
||
test.js:15:29 | ||
15| const error1: Props = {foo: 3}; | ||
^ [1] | ||
|
||
References: | ||
test.js:11:28 | ||
11| [StringPrefix<'data-'>]: string | void, | ||
^^^^^^ [2] | ||
test.js:11:37 | ||
11| [StringPrefix<'data-'>]: string | void, | ||
^^^^ [3] | ||
|
||
|
||
|
||
Found 2 errors | ||
|
||
Only showing the most relevant union/intersection branches. | ||
To see all branches, re-run Flow with --show-all-branches | ||
Found 1 error |
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
Oops, something went wrong.