Skip to content

Update @rescript/react dependency in workspace and use it for more tests #7525

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

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis/examples/larger-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"dependencies": {
"@glennsl/bs-json": "^5.0.4",
"@rescript/react": "^0.10.3"
"@rescript/react": "workspace:^"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"tests/dependencies/**",
"tests/analysis_tests/**",
"tests/gentype_tests/**",
"tests/tests",
"tests/tools_tests"
],
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"upload-bundle": "node scripts/upload_bundle.mjs"
},
"dependencies": {
"@rescript/react": "^0.13.1",
"@rescript/react": "workspace:^",
"rescript": "workspace:^"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/playground/src/App.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ shopt -s extglob

dune build @fmt --auto-promote

files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*")
files=$(find runtime tests packages -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*")
./cli/rescript.js format $files

yarn format
2 changes: 1 addition & 1 deletion scripts/format_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case "$(uname -s)" in
fi

echo "Checking ReScript code formatting..."
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*")
files=$(find runtime tests packages -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*")
if ./cli/rescript.js format -check $files; then
printf "${successGreen}✅ ReScript code formatting ok.${reset}\n"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
addValueDeclaration +make Hooks.res:63:6 path:+Hooks.RenderPropRequiresConversion
addRecordLabelDeclaration name Hooks.res:1:16 path:+Hooks.vehicle
addRecordLabelDeclaration vehicle Hooks.res:4:12 path:+Hooks.props
addValueReference Hooks.res:5:26 --> React.res:134:0
addValueReference Hooks.res:5:26 --> React.res:135:0
addTypeReference Hooks.res:10:29 --> Hooks.res:1:16
addValueReference Hooks.res:10:29 --> Hooks.res:4:12
addValueReference Hooks.res:10:75 --> Hooks.res:5:7
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-reanalyze/deadcode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean": "rescript clean -with-deps"
},
"dependencies": {
"@rescript/react": "link:../../../dependencies/rescript-react",
"@rescript/react": "workspace:^",
"rescript": "workspace:^"
}
}
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean": "rescript clean -with-deps"
},
"dependencies": {
"@rescript/react": "link:../../dependencies/rescript-react",
"@rescript/react": "workspace:^",
"rescript": "workspace:^"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -865,13 +865,13 @@ ContextPath CArgument Value[fnTakingCallback]($2)
ContextPath Value[fnTakingCallback]
Path fnTakingCallback
[{
"label": "event => event",
"label": "mouse => mouse",
"kind": 12,
"tags": [],
"detail": "ReactEvent.Mouse.t => unit",
"documentation": null,
"sortText": "A",
"insertText": "${1:event} => ${0:event}",
"insertText": "${1:mouse} => ${0:mouse}",
"insertTextFormat": 2
}]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,7 @@ ContextPath CArgument CArgument Value[reactEventFn]($0)($0)
ContextPath CArgument Value[reactEventFn]($0)
ContextPath Value[reactEventFn]
Path reactEventFn
CPPipe pathFromEnv:ReactEvent.Mouse found:false
Path ReactEvent.Mouse.pr
Path pr
[{
"label": "ReactEvent.Mouse.preventDefault",
"kind": 12,
"tags": [],
"detail": "t => unit",
"documentation": null
}]
[]

Complete src/CompletionInferValues.res 41:50
posCursor:[41:50] posNoWhite:[41:49] Found expr:[41:11->41:56]
Expand All @@ -275,17 +266,7 @@ Path event
ContextPath CArgument CJsxPropValue [div] onMouseEnter($0)
ContextPath CJsxPropValue [div] onMouseEnter
Path ReactDOM.domProps
Path JsxDOM.domProps
CPPipe pathFromEnv:JsxEvent.Mouse found:false
Path JsxEvent.Mouse.pr
Path pr
[{
"label": "JsxEvent.Mouse.preventDefault",
"kind": 12,
"tags": [],
"detail": "t => unit",
"documentation": null
}]
[]

Complete src/CompletionInferValues.res 44:50
posCursor:[44:50] posNoWhite:[44:49] Found expr:[44:11->44:56]
Expand Down Expand Up @@ -832,22 +813,7 @@ ContextPath CArgument CArgument Value[fn2](~cb)($0)
ContextPath CArgument Value[fn2](~cb)
ContextPath Value[fn2]
Path fn2
CPPipe pathFromEnv:ReactDOM.Client.Root found:false
Path ReactDOM.Client.Root.
Path
[{
"label": "ReactDOM.Client.Root.unmount",
"kind": 12,
"tags": [],
"detail": "(t, unit) => unit",
"documentation": null
}, {
"label": "ReactDOM.Client.Root.render",
"kind": 12,
"tags": [],
"detail": "(t, React.element) => unit",
"documentation": null
}]
[]

Complete src/CompletionInferValues.res 139:30
posCursor:[139:30] posNoWhite:[139:29] Found expr:[139:3->139:33]
Expand Down Expand Up @@ -974,22 +940,7 @@ ContextPath CArgument CArgument Value[CompletionSupport2, makeRenderer](~render)
ContextPath CArgument Value[CompletionSupport2, makeRenderer](~render)
ContextPath Value[CompletionSupport2, makeRenderer]
Path CompletionSupport2.makeRenderer
CPPipe pathFromEnv:ReactDOM.Client.Root found:false
Path ReactDOM.Client.Root.
Path
[{
"label": "ReactDOM.Client.Root.unmount",
"kind": 12,
"tags": [],
"detail": "(t, unit) => unit",
"documentation": null
}, {
"label": "ReactDOM.Client.Root.render",
"kind": 12,
"tags": [],
"detail": "(t, React.element) => unit",
"documentation": null
}]
[]

Hover src/CompletionInferValues.res 160:27
Nothing at that position. Now trying to use completion.
Expand Down
10 changes: 2 additions & 8 deletions tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,8 @@ Completable: Cjsx([h1], hidd, [hidd])
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
Path ReactDOM.domProps
Path JsxDOM.domProps
[{
"label": "hidden",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}]
[completing-lowercase-jsx] could not find element props to complete from.
[]

Complete src/CompletionJsx.res 61:30
posCursor:[61:30] posNoWhite:[61:28] Found expr:[61:3->61:29]
Expand Down
27 changes: 2 additions & 25 deletions tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
ContextPath CJsxPropValue [div] muted
Path ReactDOM.domProps
Path JsxDOM.domProps
[{
"label": "true",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}, {
"label": "false",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}]
[]

Complete src/CompletionJsxProps.res 18:29
posCursor:[18:29] posNoWhite:[18:28] Found expr:[18:11->18:32]
Expand All @@ -246,17 +233,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
ContextPath CJsxPropValue [div] onMouseEnter
Path ReactDOM.domProps
Path JsxDOM.domProps
[{
"label": "event => event",
"kind": 12,
"tags": [],
"detail": "JsxEvent.Mouse.t => unit",
"documentation": null,
"sortText": "A",
"insertText": "{${1:event} => ${0:event}}",
"insertTextFormat": 2
}]
[]

Complete src/CompletionJsxProps.res 22:52
posCursor:[22:52] posNoWhite:[22:51] Found expr:[22:11->22:52]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,7 @@ Path support
CPPipe pathFromEnv:CompletionSupport.Nested found:false
Path CompletionSupport.Nested.root
Path root
CPPipe pathFromEnv:ReactDOM.Client.Root found:false
Path ReactDOM.Client.Root.ren
Path ren
[{
"label": "ReactDOM.Client.Root.render",
"kind": 12,
"tags": [],
"detail": "(t, React.element) => unit",
"documentation": null
}]
[]

Complete src/CompletionPipeChain.res 88:16
posCursor:[88:16] posNoWhite:[88:15] Found expr:[76:15->93:1]
Expand All @@ -496,16 +487,7 @@ Resolved opens 1 Stdlib
ContextPath Value[root]->ren
ContextPath Value[root]
Path root
CPPipe pathFromEnv:ReactDOM.Client.Root found:false
Path ReactDOM.Client.Root.ren
Path ren
[{
"label": "ReactDOM.Client.Root.render",
"kind": 12,
"tags": [],
"detail": "(t, React.element) => unit",
"documentation": null
}]
[]

Complete src/CompletionPipeChain.res 95:20
posCursor:[95:20] posNoWhite:[95:19] Found expr:[95:3->95:21]
Expand Down
10 changes: 2 additions & 8 deletions tests/analysis_tests/tests/src/expected/Div.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ Completable: Cjsx([div], dangerous, [dangerous])
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
Path ReactDOM.domProps
Path JsxDOM.domProps
[{
"label": "dangerouslySetInnerHTML",
"kind": 4,
"tags": [],
"detail": "{\"__html\": string}",
"documentation": null
}]
[completing-lowercase-jsx] could not find element props to complete from.
[]

2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/src/expected/Fragment.res.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hover src/Fragment.res 6:19
{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<SectionHeader.props<React.element>>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype SectionHeader.props<'children> = {children: 'children}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Fragment.res%22%2C1%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}}
{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<SectionHeader.props<React.element>>\n```\n\n---\n\n```\n \n```\n```rescript\ntype SectionHeader.props<'children> = {children: 'children}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Fragment.res%22%2C1%2C2%5D)\n"}}

Hover src/Fragment.res 9:56
Nothing at that position. Now trying to use completion.
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/src/expected/Hover.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Path
}]

Hover src/Hover.res 197:4
{"contents": {"kind": "markdown", "value": "```rescript\nCompV4.props<int, string> => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype CompV4.props<'n, 's> = {n?: 'n, s: 's}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C190%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}}
{"contents": {"kind": "markdown", "value": "```rescript\nCompV4.props<int, string> => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype CompV4.props<'n, 's> = {n?: 'n, s: 's}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C190%2C2%5D)\n"}}

Hover src/Hover.res 202:16
{"contents": {"kind": "markdown", "value": "```rescript\nuseR\n```\n\n---\n\n```\n \n```\n```rescript\ntype useR = {x: int, y: list<option<r<float>>>}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C200%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype r<'a> = {i: 'a, f: float}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C101%2C0%5D)\n"}}
Expand Down
20 changes: 2 additions & 18 deletions tests/analysis_tests/tests/src/expected/Jsx2.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
ContextPath Type[React, e]
Path React.e
[{
"label": "element",
"kind": 22,
"tags": [],
"detail": "type element",
"documentation": {"kind": "markdown", "value": "```rescript\ntype element = Jsx.element\n```"}
}]
[]

Complete src/Jsx2.res 96:20
posCursor:[96:20] posNoWhite:[96:19] Found pattern:[96:7->99:6]
Expand Down Expand Up @@ -472,17 +466,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
ContextPath CJsxPropValue [div] x
Path ReactDOM.domProps
Path JsxDOM.domProps
[{
"label": "\"\"",
"kind": 12,
"tags": [],
"detail": "string",
"documentation": null,
"sortText": "A",
"insertText": "{\"$0\"}",
"insertTextFormat": 2
}]
[]

Complete src/Jsx2.res 150:21
posCursor:[150:21] posNoWhite:[150:20] Found expr:[150:11->150:32]
Expand Down
16 changes: 2 additions & 14 deletions tests/analysis_tests/tests/src/expected/Jsx2.resi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
ContextPath Type[React, e]
Path React.e
[{
"label": "element",
"kind": 22,
"tags": [],
"detail": "type element",
"documentation": {"kind": "markdown", "value": "```rescript\ntype element = Jsx.element\n```"}
}]
[]

Complete src/Jsx2.resi 10:18
posCursor:[10:18] posNoWhite:[10:17] Found type:[10:11->10:18]
Expand All @@ -28,11 +22,5 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder
Resolved opens 1 Stdlib
ContextPath Type[React, e]
Path React.e
[{
"label": "element",
"kind": 22,
"tags": [],
"detail": "type element",
"documentation": {"kind": "markdown", "value": "```rescript\ntype element = Jsx.element\n```"}
}]
[]

2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/src/expected/JsxV4.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Path M4.make
}]

Hover src/JsxV4.res 14:9
{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<M4.props<string, string, string>>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype M4.props<'first, 'fun, 'second> = {\n first: 'first,\n fun?: 'fun,\n second?: 'second,\n}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22JsxV4.res%22%2C3%2C2%5D)\n\n---\n Doc Comment For M4 "}}
{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<M4.props<string, string, string>>\n```\n\n---\n\n```\n \n```\n```rescript\ntype M4.props<'first, 'fun, 'second> = {\n first: 'first,\n fun?: 'fun,\n second?: 'second,\n}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22JsxV4.res%22%2C3%2C2%5D)\n\n---\n Doc Comment For M4 "}}

Create Interface src/JsxV4.res
module M4: {
Expand Down
21 changes: 21 additions & 0 deletions tests/dependencies/rescript-react/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Sander, 2020 The ReScript Project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading