Skip to content

Test create interface file JSX V4. #636

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

Closed
wants to merge 1 commit into from
Closed
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/tests/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"bsc-flags": ["-w -33-44"],
"bs-dependencies": ["@rescript/react"],
"jsx": { "version": 3 }
"jsx": { "version": 4 }
}
2 changes: 1 addition & 1 deletion analysis/tests/src/expected/CodeLens.res.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Code Lens src/CodeLens.res
[{
"range": {"start": {"line": 9, "character": 4}, "end": {"line": 9, "character": 8}},
"command": {"title": "{\"name\": string} => React.element", "command": ""}
"command": {"title": "'name", "command": ""}
}, {
"range": {"start": {"line": 4, "character": 4}, "end": {"line": 4, "character": 6}},
"command": {"title": "(~opt1: int=?, ~a: int, ~b: int, unit, ~opt2: int=?, unit, ~c: int) => int", "command": ""}
Expand Down
40 changes: 20 additions & 20 deletions analysis/tests/src/expected/CreateInterface.res.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Create Interface src/CreateInterface.res
type r = {name: string, age: int}
let add: (~x: int, ~y: int) => int
@react.component
let make: (~name: string) => React.element
type props<'name> = {name: 'name}
let make: props<string> => React.element
module Other: {
@react.component
let otherComponentName: (~name: string) => React.element
type props<'name> = {name: 'name}
let otherComponentName: props<string> => React.element
}
module Mod: {
@react.component
let make: (~name: string) => React.element
type props<'name> = {name: 'name}
let make: props<string> => React.element
}
module type ModTyp = {
@react.component
let make: (~name: string) => React.element
type props<'name> = {name: 'name}
let make: React.componentLike<props<string>, React.element>
}
@module("path") external dirname: string => string = "dirname"
@module("path") @variadic
Expand Down Expand Up @@ -55,15 +55,15 @@ module type FT = {
module Functor: (
X: {
let a: int
@react.component
let make: (~name: string) => React.element
type props<'name> = {name: 'name}
let make: React.componentLike<props<string>, React.element>
let b: int
},
Y: ModTyp,
) =>
{
@react.component
let make: (~name: string) => React.element
type props<'name> = {name: 'name}
let make: React.componentLike<props<string>, React.element>
}
}
module NormaList = List
Expand All @@ -79,8 +79,8 @@ module type OptT = {
let withOpt2: (~x: int=?, ~y: int) => int
}
module type Opt3 = {
@react.component
let withOpt3: (~x: option<int>, ~y: int) => int
type props<'x, 'y> = {x: 'x, y: 'y}
let withOpt3: React.componentLike<props<option<int>, int>, int>
}
}
module Opt: {
Expand All @@ -95,18 +95,18 @@ module Opt: {
let withOpt2: (~x: int=?, ~y: int) => int
}
module Opt3: {
@react.component
let withOpt3: (~x: option<int>, ~y: int) => int
type props<'x, 'y> = {x: 'x, y: 'y}
let withOpt3: props<option<int>, int> => int
}
module type Opt3 = {
@react.component
let withOpt3: (~x: option<int>, ~y: int) => int
type props<'x, 'y> = {x: 'x, y: 'y}
let withOpt3: props<option<int>, int> => int
}
}
module Opt2: OptT
module Opt3 = Opt
module Memo: {
@react.component
let make: (~name: string) => React.element
type props<'name> = {name: 'name}
let make: React.component<props<string>>
}

3 changes: 1 addition & 2 deletions analysis/tests/src/expected/Div.res.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Hover src/Div.res 0:10
getLocItem #3: heuristic for <div>
{"contents": {"kind": "markdown", "value": "```rescript\n(\n string,\n ~props: ReactDOM_V3.domProps=?,\n array<React.element>,\n) => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype ReactDOM_V3.domProps = Props.domProps\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22ReactDOM_V3.res%22%2C57%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\nstring\n```"}}

Complete src/Div.res 3:17
posCursor:[3:17] posNoWhite:[3:16] Found expr:[3:4->3:17]
Expand Down
4 changes: 1 addition & 3 deletions analysis/tests/src/expected/Fragment.res.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Hover src/Fragment.res 6:19
getLocItem #4: heuristic for </Comp> within fragments: take make as makeProps does not work
the type is not great but jump to definition works
{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<{\"children\": 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"}}
{"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"}}

Hover src/Fragment.res 9:56
Nothing at that position. Now trying to use completion.
Expand Down
10 changes: 0 additions & 10 deletions analysis/tests/src/expected/Hover.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,9 @@ Hover src/Hover.res 33:4
{"contents": {"kind": "markdown", "value": "```rescript\nunit => int\n```\n\nDoc comment for functionWithTypeAnnotation"}}

Hover src/Hover.res 37:13
getLocItem #5: heuristic for JSX and compiler combined:
~x becomes Props#x
heuristic for: [Props, x], give loc of `x`
n1:Props n2:name
{"contents": {"kind": "markdown", "value": "```rescript\nstring\n```"}}

Hover src/Hover.res 42:15
getLocItem #7: heuristic for JSX on type-annotated labeled (~arg:t):
(~arg:t) becomes Props#arg
Props has the location range of arg:t
arg has the location range of arg
heuristic for: [Props, arg], give loc of `arg`
n1:Props n2:name
{"contents": {"kind": "markdown", "value": "```rescript\nstring\n```"}}

Hover src/Hover.res 46:10
Expand Down
4 changes: 0 additions & 4 deletions analysis/tests/src/expected/Jsx2.res.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Definition src/Jsx2.res 5:9
getLocItem #4: heuristic for </Comp> within fragments: take make as makeProps does not work
the type is not great but jump to definition works
{"uri": "Jsx2.res", "range": {"start": {"line": 2, "character": 6}, "end": {"line": 2, "character": 10}}}

Complete src/Jsx2.res 8:15
Expand Down Expand Up @@ -204,8 +202,6 @@ Completable: Cjsx([M], k, [prop, k])
}]

Definition src/Jsx2.res 58:11
getLocItem #4: heuristic for </Comp> within fragments: take make as makeProps does not work
the type is not great but jump to definition works
{"uri": "Component.res", "range": {"start": {"line": 1, "character": 4}, "end": {"line": 1, "character": 8}}}

Complete src/Jsx2.res 68:10
Expand Down
4 changes: 1 addition & 3 deletions analysis/tests/src/expected/Jsx2.resi.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Hover src/Jsx2.resi 1:4
getLocItem #1: heuristic for makeProps in interface files
n1:componentLike n2:unit n3:string
{"contents": {"kind": "markdown", "value": "```rescript\n(~first: string, ~key: string=?, unit) => {\"first\": string}\n```"}}
{"contents": {"kind": "markdown", "value": "```rescript\nprops<string>\n```\n\n---\n\n```\n \n```\n```rescript\ntype props<'first> = {first: 'first}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Jsx2.resi%22%2C0%2C0%5D)\n"}}

Hover src/Jsx2.resi 4:4
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}
Expand Down