Skip to content

group Jsx modules #7347

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion lib/es6/Jsx.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */



let DOMStyle;

let Event;

let DOM;

export {
DOMStyle,
Event,
DOM,
}
/* No side effect */
1 change: 1 addition & 0 deletions lib/es6/Jsx_common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
14 changes: 13 additions & 1 deletion lib/js/Jsx.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
'use strict';


let DOMStyle;

let Event;

let DOM;

exports.DOMStyle = DOMStyle;
exports.Event = Event;
exports.DOM = DOM;
/* No side effect */
1 change: 1 addition & 0 deletions lib/js/Jsx_common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
21 changes: 4 additions & 17 deletions runtime/Jsx.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

// Define this as a private empty record so that the compiler does not
// unnecessarily add `Primitive_option.some` calls for optional props.
type element = private {}

@val external null: element = "null"

external float: float => element = "%identity"
external int: int => element = "%identity"
external string: string => element = "%identity"

external array: array<element> => element = "%identity"

type componentLike<'props, 'return> = 'props => 'return
type component<'props> = componentLike<'props, element>

/* this function exists to prepare for making `component` abstract */
external component: componentLike<'props, element> => component<'props> = "%identity"
Comment on lines -25 to -41
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to Jsx_common.res to avoid cyclic dependency.

include Jsx_common
module DOMStyle = JsxDOMStyle
module Event = JsxEvent
module DOM = JsxDOM
3 changes: 2 additions & 1 deletion runtime/JsxDOM.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

@@deprecated("Use `Jsx.DOM` instead.")
type style = JsxDOMStyle.t
type domRef
/**
Expand All @@ -38,7 +39,7 @@ type popoverTargetAction = | @as("toggle") Toggle | @as("show") Show | @as("hide
*/
type domProps = {
key?: string,
children?: Jsx.element,
children?: Jsx_common.element,
ref?: domRef,
/* accessibility */
/* https://www.w3.org/TR/wai-aria-1.1/ */
Expand Down
1 change: 1 addition & 0 deletions runtime/JsxDOMStyle.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

@@deprecated("Use `Jsx.DOMStyle` instead.")
type t = {
/**
See [`accent-color`](https://developer.mozilla.org/docs/Web/CSS/accent-color) on MDN.
Expand Down
1 change: 1 addition & 0 deletions runtime/JsxEvent.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

@@deprecated("Use `Jsx.Event` instead.")
type synthetic<'a>

module MakeEventWithType = (
Expand Down
41 changes: 41 additions & 0 deletions runtime/Jsx_common.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright (C) 2022- Authors of ReScript
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

// Define this as a private empty record so that the compiler does not
// unnecessarily add `Primitive_option.some` calls for optional props.
type element = private {}

@val external null: element = "null"

external float: float => element = "%identity"
external int: int => element = "%identity"
external string: string => element = "%identity"

external array: array<element> => element = "%identity"

type componentLike<'props, 'return> = 'props => 'return
type component<'props> = componentLike<'props, element>

/* this function exists to prepare for making `component` abstract */
external component: componentLike<'props, element> => component<'props> = "%identity"
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/src/expected/Completion.res.txt

Large diffs are not rendered by default.

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<Jsx.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 Jsx.element = Jsx_common.element = {}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Jsx.res%22%2C0%2C-1%5D)\n"}}

Hover src/Fragment.res 9:56
Nothing at that position. Now trying to use completion.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.