-
Notifications
You must be signed in to change notification settings - Fork 471
Improve various error messages #7500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b1ca40
improve array <-> tuple error message by looking at what the user act…
zth 6a28ea9
refactor
zth a8378e6
example of detecting and providing rewrite for ReScript object -> record
zth fa7e483
remove Belt prefix
zth 991dfb6
add dedicated JSX element type mismatch errors
zth 9f03508
note that you need to unwrap options in JSX
zth 4f30225
fix
zth aa1856a
add simple error message indicating dict syntax
zth 2f2dcb7
changelog
zth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add dedicated JSX element type mismatch errors
- Loading branch information
commit 991dfb616f70193f77c5aa98f3fc70b64b847696
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
13 changes: 13 additions & 0 deletions
13
tests/build_tests/super_errors/expected/jsx_type_mismatch_array_element.res.expected
This file contains hidden or 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 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/jsx_type_mismatch_array_element.res[0m:[2m19:13-30[0m | ||
|
||
17 [2m│[0m } | ||
18 [2m│[0m | ||
[1;31m19[0m [2m│[0m let x = <> {[1;31m[React.string("")][0m} </> | ||
20 [2m│[0m | ||
|
||
This has type: [1;31marray<'a>[0m | ||
But it's expected to have type: [1;33mReact.element[0m [2m(defined as[0m [1;33mJsx.element[0m[2m)[0m | ||
|
||
You need to convert each item in this array to a JSX element first, then use [1;33mReact.array[0m to convert the array of JSX elements into a single JSX element. |
13 changes: 13 additions & 0 deletions
13
tests/build_tests/super_errors/expected/jsx_type_mismatch_array_raw.res.expected
This file contains hidden or 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 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/jsx_type_mismatch_array_raw.res[0m:[2m17:13-16[0m | ||
|
||
15 [2m│[0m } | ||
16 [2m│[0m | ||
[1;31m17[0m [2m│[0m let x = <> {[1;31m[""][0m} </> | ||
18 [2m│[0m | ||
|
||
This has type: [1;31marray<'a>[0m | ||
But it's expected to have type: [1;33mReact.element[0m [2m(defined as[0m [1;33mJsx.element[0m[2m)[0m | ||
|
||
You need to convert each item in this array to a JSX element first, then use [1;33mReact.array[0m to convert the array of JSX elements into a single JSX element. |
13 changes: 13 additions & 0 deletions
13
tests/build_tests/super_errors/expected/jsx_type_mismatch_float.res.expected
This file contains hidden or 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 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/jsx_type_mismatch_float.res[0m:[2m17:13-14[0m | ||
|
||
15 [2m│[0m } | ||
16 [2m│[0m | ||
[1;31m17[0m [2m│[0m let x = <> {[1;31m1.[0m} </> | ||
18 [2m│[0m | ||
|
||
This has type: [1;31mfloat[0m | ||
But it's expected to have type: [1;33mReact.element[0m [2m(defined as[0m [1;33mJsx.element[0m[2m)[0m | ||
|
||
In JSX, all content must be JSX elements. You can convert float to a JSX element with [1;33mReact.float[0m. |
13 changes: 13 additions & 0 deletions
13
tests/build_tests/super_errors/expected/jsx_type_mismatch_int.res.expected
This file contains hidden or 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 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/jsx_type_mismatch_int.res[0m:[2m17:13[0m | ||
|
||
15 [2m│[0m } | ||
16 [2m│[0m | ||
[1;31m17[0m [2m│[0m let x = <> {[1;31m1[0m} </> | ||
18 [2m│[0m | ||
|
||
This has type: [1;31mint[0m | ||
But it's expected to have type: [1;33mReact.element[0m [2m(defined as[0m [1;33mJsx.element[0m[2m)[0m | ||
|
||
In JSX, all content must be JSX elements. You can convert int to a JSX element with [1;33mReact.int[0m. |
13 changes: 13 additions & 0 deletions
13
tests/build_tests/super_errors/expected/jsx_type_mismatch_string.res.expected
This file contains hidden or 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 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/jsx_type_mismatch_string.res[0m:[2m17:13-14[0m | ||
|
||
15 [2m│[0m } | ||
16 [2m│[0m | ||
[1;31m17[0m [2m│[0m let x = <> {[1;31m""[0m} </> | ||
18 [2m│[0m | ||
|
||
This has type: [1;31mstring[0m | ||
But it's expected to have type: [1;33mReact.element[0m [2m(defined as[0m [1;33mJsx.element[0m[2m)[0m | ||
|
||
In JSX, all content must be JSX elements. You can convert string to a JSX element with [1;33mReact.string[0m. |
19 changes: 19 additions & 0 deletions
19
tests/build_tests/super_errors/fixtures/jsx_type_mismatch_array_element.res
This file contains hidden or 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,19 @@ | ||
@@config({ | ||
flags: ["-bs-jsx", "4"], | ||
}) | ||
|
||
module React = { | ||
type element = Jsx.element | ||
type componentLike<'props, 'return> = 'props => 'return | ||
type component<'props> = Jsx.component<'props> | ||
|
||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
|
||
type fragmentProps = {children?: element} | ||
@module("react/jsx-runtime") external jsxFragment: component<fragmentProps> = "Fragment" | ||
|
||
external string: string => element = "%identity" | ||
} | ||
|
||
let x = <> {[React.string("")]} </> |
17 changes: 17 additions & 0 deletions
17
tests/build_tests/super_errors/fixtures/jsx_type_mismatch_array_raw.res
This file contains hidden or 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,17 @@ | ||
@@config({ | ||
flags: ["-bs-jsx", "4"], | ||
}) | ||
|
||
module React = { | ||
type element = Jsx.element | ||
type componentLike<'props, 'return> = 'props => 'return | ||
type component<'props> = Jsx.component<'props> | ||
|
||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
|
||
type fragmentProps = {children?: element} | ||
@module("react/jsx-runtime") external jsxFragment: component<fragmentProps> = "Fragment" | ||
} | ||
|
||
let x = <> {[""]} </> |
17 changes: 17 additions & 0 deletions
17
tests/build_tests/super_errors/fixtures/jsx_type_mismatch_float.res
This file contains hidden or 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,17 @@ | ||
@@config({ | ||
flags: ["-bs-jsx", "4"], | ||
}) | ||
|
||
module React = { | ||
type element = Jsx.element | ||
type componentLike<'props, 'return> = 'props => 'return | ||
type component<'props> = Jsx.component<'props> | ||
|
||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
|
||
type fragmentProps = {children?: element} | ||
@module("react/jsx-runtime") external jsxFragment: component<fragmentProps> = "Fragment" | ||
} | ||
|
||
let x = <> {1.} </> |
17 changes: 17 additions & 0 deletions
17
tests/build_tests/super_errors/fixtures/jsx_type_mismatch_int.res
This file contains hidden or 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,17 @@ | ||
@@config({ | ||
flags: ["-bs-jsx", "4"], | ||
}) | ||
|
||
module React = { | ||
type element = Jsx.element | ||
type componentLike<'props, 'return> = 'props => 'return | ||
type component<'props> = Jsx.component<'props> | ||
|
||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
|
||
type fragmentProps = {children?: element} | ||
@module("react/jsx-runtime") external jsxFragment: component<fragmentProps> = "Fragment" | ||
} | ||
|
||
let x = <> {1} </> |
17 changes: 17 additions & 0 deletions
17
tests/build_tests/super_errors/fixtures/jsx_type_mismatch_string.res
This file contains hidden or 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,17 @@ | ||
@@config({ | ||
flags: ["-bs-jsx", "4"], | ||
}) | ||
|
||
module React = { | ||
type element = Jsx.element | ||
type componentLike<'props, 'return> = 'props => 'return | ||
type component<'props> = Jsx.component<'props> | ||
|
||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
|
||
type fragmentProps = {children?: element} | ||
@module("react/jsx-runtime") external jsxFragment: component<fragmentProps> = "Fragment" | ||
} | ||
|
||
let x = <> {""} </> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
process_file
is the appropriate place to run this, but maybe there's a better place, idk.