-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSX component error message improvements (#7038)
* improve component prop not existing error * improve JSX component missing props error message * improve component prop passed multiple times error * add attribute in interface files too * make function * add tests * changelog * tweak error message * fix location and message of JSX component prop passed multiple times * sync syntax roundtrip tests * try pointing to label instead of expr for error highlight
- Loading branch information
Showing
37 changed files
with
261 additions
and
57 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
11 changes: 11 additions & 0 deletions
11
jscomp/build_tests/super_errors/expected/component_invalid_prop.res.expected
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,11 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/component_invalid_prop.res[0m:[2m7:5-8[0m | ||
|
||
5 [2m│[0m | ||
6 [2m│[0m let make = (): props<'name> => { | ||
[1;31m7[0m [2m│[0m [1;31mtest[0m: false, | ||
8 [2m│[0m } | ||
9 [2m│[0m } | ||
|
||
The prop [1;31mtest[0m does not belong to the JSX component |
16 changes: 8 additions & 8 deletions
16
jscomp/build_tests/super_errors/expected/component_missing_prop.res.expected
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,12 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/component_missing_prop.res[0m:[2m5:34-35[0m | ||
[36m/.../fixtures/component_missing_prop.res[0m:[2m6:34-35[0m | ||
|
||
3 [2m│[0m type props<'name> = {name: 'name} | ||
4 [2m│[0m | ||
[1;31m5[0m [2m│[0m let make = (): props<'name> => [1;31m{}[0m | ||
6 [2m│[0m } | ||
7 [2m│[0m | ||
4 [2m│[0m type props<'name> = {name: 'name} | ||
5 [2m│[0m | ||
[1;31m6[0m [2m│[0m let make = (): props<'name> => [1;31m{}[0m | ||
7 [2m│[0m } | ||
8 [2m│[0m | ||
|
||
Some required record fields are missing: | ||
name. If this is a component, add the missing props. | ||
The component is missing these required props: | ||
name |
12 changes: 12 additions & 0 deletions
12
jscomp/build_tests/super_errors/expected/component_prop_passed_multiple_times.res.expected
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,12 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/component_prop_passed_multiple_times.res[0m:[2m8:5-8[0m | ||
|
||
6 [2m│[0m let make = (): props<'name> => { | ||
7 [2m│[0m name: "hello", | ||
[1;31m8[0m [2m│[0m [1;31mname[0m: "world", | ||
9 [2m│[0m } | ||
10 [2m│[0m } | ||
|
||
The prop [1;33mname[0m has already been passed to the component | ||
You can't pass the same prop more than once. |
9 changes: 9 additions & 0 deletions
9
jscomp/build_tests/super_errors/fixtures/component_invalid_prop.res
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,9 @@ | ||
// Since the React transform isn't active in the tests, mimic what the transform outputs. | ||
module Component = { | ||
@res.jsxComponentProps | ||
type props<'name> = {name: 'name} | ||
|
||
let make = (): props<'name> => { | ||
test: false, | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
jscomp/build_tests/super_errors/fixtures/component_missing_prop.res
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
10 changes: 10 additions & 0 deletions
10
jscomp/build_tests/super_errors/fixtures/component_prop_passed_multiple_times.res
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,10 @@ | ||
// Since the React transform isn't active in the tests, mimic what the transform outputs. | ||
module Component = { | ||
@res.jsxComponentProps | ||
type props<'name> = {name: 'name} | ||
|
||
let make = (): props<'name> => { | ||
name: "hello", | ||
name: "world", | ||
} | ||
} |
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
Oops, something went wrong.