Skip to content

Remove JSX v3 #7072

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 7 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
remove makeProps from tests
  • Loading branch information
mununki committed Oct 4, 2024
commit 4147e42d60503fae7bb5f00b2bc48fb0ce1a3993
5 changes: 0 additions & 5 deletions jscomp/syntax/tests/idempotency/nook-exchange/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ external gtag: option<(. string, string, {"page_path": string}) => unit> = "gtag

module TooltipConfigContextProvider = {
type tooltipModifiers = array<{"name": string, "options": {"offset": array<int>}}>
let makeProps = (~value, ~children, ()) =>
{
"value": value,
"children": children,
}
let make = React.Context.provider(
(
ReactAtmosphere.Tooltip.configContext: React.Context.t<
Expand Down
58 changes: 35 additions & 23 deletions jscomp/syntax/tests/idempotency/reason-react/src/React.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ type element

@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"
Expand All @@ -20,14 +22,29 @@ external cloneElement: (component<'props>, 'props) => element = "cloneElement"
external createElementVariadic: (component<'props>, 'props, array<element>) => element =
"createElement"

@module("react/jsx-runtime")
external jsx: (component<'props>, 'props) => element = "jsx"

@module("react/jsx-runtime")
external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsx"

@module("react/jsx-runtime")
external jsxs: (component<'props>, 'props) => element = "jsxs"

@module("react/jsx-runtime")
external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs"

type ref<'value> = {mutable current: 'value}

module Ref = {
type t<'value>

@get external current: t<'value> => 'value = "current"
@set external setCurrent: (t<'value>, 'value) => unit = "current"
}

@module("react") external createRef: unit => Ref.t<Js.nullable<'a>> = "createRef"
@module("react")
external createRef: unit => Ref.t<Js.nullable<'a>> = "createRef"

module Children = {
@module("react") @scope("Children") @val
Expand All @@ -43,13 +60,19 @@ module Children = {
}

module Context = {
type t<'props>
type t<'context>

type props<'context> = {
value: 'context,
children: element,
}

@get
external provider: t<'props> => component<{"value": 'props, "children": element}> = "Provider"
external provider: t<'context> => component<props<'context>> = "Provider"
}

@module("react") external createContext: 'a => Context.t<'a> = "createContext"
@module("react")
external createContext: 'a => Context.t<'a> = "createContext"

@module("react")
external forwardRef: (('props, Js.Nullable.t<Ref.t<'a>>) => element) => component<'props> =
Expand All @@ -65,29 +88,17 @@ external memoCustomCompareProps: (
) => component<'props> = "memo"

module Fragment = {
@obj
external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = ""
type props = {key?: string, children: element}

@module("react")
external make: component<{
"children": element,
}> = "Fragment"
external make: component<props> = "Fragment"
}

module Suspense = {
@obj
external makeProps: (
~children: element=?,
~fallback: element=?,
~maxDuration: int=?,
~key: 'key=?,
unit,
) => {"children": option<element>, "fallback": option<element>, "maxDuration": option<int>} = ""
type props = {key?: string, children?: element, fallback?: element}

@module("react")
external make: component<{
"children": option<element>,
"fallback": option<element>,
"maxDuration": option<int>,
}> = "Suspense"
external make: component<props> = "Suspense"
}

/* HOOKS */
Expand Down Expand Up @@ -228,7 +239,8 @@ external useCallback7: (
('a, 'b, 'c, 'd, 'e, 'f, 'g),
) => callback<'input, 'output> = "useCallback"

@module("react") external useContext: Context.t<'any> => 'any = "useContext"
@module("react")
external useContext: Context.t<'any> => 'any = "useContext"

@module("react") external useRef: 'value => Ref.t<'value> = "useRef"

Expand Down
18 changes: 5 additions & 13 deletions jscomp/syntax/tests/idempotency/reasonml.org/common/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
hljs.registerLanguage('text', text);
`)

type pageComponent = React.component<{.}>
type pageProps = {.}
type pageProps = {}
type pageComponent = React.component<pageProps>

type props = {"Component": pageComponent, "pageProps": pageProps}
type props = {@as("Component") component: pageComponent, pageProps: pageProps}

module Url = {
type version =
Expand Down Expand Up @@ -116,17 +116,9 @@ module Url = {
}
}

@obj
external makeProps: (
~component: pageComponent,
~pageProps: pageProps,
~key: string=?,
unit,
) => props = ""

let make = (props: props): React.element => {
let component = props["Component"]
let pageProps = props["pageProps"]
let component = props.component
let pageProps = props.pageProps

let router = Next.Router.useRouter()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ module Make = (Config: Config) => {

module ContextProvider = {
let make = React.Context.provider(storeContext)
let makeProps = (
~value: option<Reductive.Store.t<Config.action, Config.state>>,
~children,
(),
) =>
{
"value": value,
"children": children,
}
}

module Provider = {
Expand Down
16 changes: 5 additions & 11 deletions jscomp/syntax/tests/idempotency/reductive/reductiveContext.resi
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ module type Config = {
module Make: (Config: Config) =>
{
module Provider: {
@obj
external makeProps: (
~children: 'children,
~store: Reductive.Store.t<Config.action, Config.state>,
~key: string=?,
unit,
) => {"children": 'children, "store": Reductive.Store.t<Config.action, Config.state>} = ""
let make: {
"children": React.element,
"store": Reductive.Store.t<Config.action, Config.state>,
} => React.element
@react.component
let make: (
~children: React.element,
~store: Reductive.Store.t<Config.action, Config.state>
) => React.element
}
let useSelector: (Config.state => 'selectedState) => 'selectedState
let useDispatch: (unit, Config.action) => unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let unsafePlaceholder: module(T) = %raw(`{}`)

module UnsafePlaceholder = unpack(unsafePlaceholder)

let makeProps = UnsafePlaceholder.makeProps
type props = UnsafePlaceholder.props

let make = ReLoadable.lazy_(() =>
ReLoadable.\"import"(UnsafePlaceholder.make, "./ThreeBoxUpdate.bs.js")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ module TranslationContext = {
setTranslationModeCrypto: _ => (),
})

let makeProps = (~value, ~children, ()) =>
{
"value": value,
"children": children,
}

let make = React.Context.provider(translationContext)
}
let useTranslationModeContext = () => React.useContext(TranslationContext.translationContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ module RootContext = {
let context = React.createContext((initialState, _ => ()))
// Create a provider component
let make = React.Context.provider(context)

// Tell bucklescript how to translate props into JS
let makeProps = (~value, ~children, ()) =>
{
"value": value,
"children": children,
}
}

module RootWithWeb3 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ let initialState = {usdPrice: None}
module PriceProvider = {
let context: React.Context.t<option<float>> = React.createContext(None)
let make = React.Context.provider(context)

@ocaml.doc(" Tell bucklescript how to translate props into JS ")
let makeProps = (~value, ~children, ()) =>
{
"value": value,
"children": children,
}
}

@decco @deriving(accessors)
Expand Down
2 changes: 2 additions & 0 deletions tests/build_tests/react_ppx/src/React.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ external jsxs: (component<'props>, 'props) => element = "jsxs"
@module("react/jsx-runtime")
external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs"

type ref<'value> = {mutable current: 'value}

module Ref = {
type t<'value>

Expand Down
8 changes: 1 addition & 7 deletions tests/tests/src/gpr_3519_test.js

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

6 changes: 0 additions & 6 deletions tests/tests/src/gpr_3519_test.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
module Foo: {
@obj external makeProps: (~bar: array<string>=?) => string = ""
} = {
@obj external makeProps: (~bar: 'bar=?) => string = ""
}

type arra<'a> = array<'a>

@send @variadic external f0: (int, int, int, array<int>) => unit = "f0"
Expand Down
18 changes: 0 additions & 18 deletions tests/tests/src/gpr_5071_test.js

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

14 changes: 0 additions & 14 deletions tests/tests/src/gpr_5071_test.res
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
@@config({
flags: ["-w", "-16"],
})
module Test: {
@obj
external makeProps: (~s: string=?, unit) => {"s": string} = ""
} = {
@obj
external makeProps: (~s: 's=?, unit) => {"s": 's} = ""
}

let u = Test.makeProps(~s="hello", ())

let f = (~s=?, y) => {
Test.makeProps(~s?, ())->Js.log
Js.log(y)
}

module H: {
@react.component
Expand Down
6 changes: 0 additions & 6 deletions tests/tests/src/react.js

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

Loading