Skip to content

deprecate other @obj #825

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 2 commits into from
Jan 17, 2025
Merged
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
20 changes: 12 additions & 8 deletions src/apis/Animated.res
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ external parallel: (array<Animation.t>, parallelPayload) => Animation.t = "paral
@module("react-native") @scope("Animated")
external stagger: (float, array<Animation.t>) => Animation.t = "stagger"

type loopConfig

@obj external loopConfig: (~iterations: int) => loopConfig = ""
type loopConfig = {iterations?: int, resetBeforeIteration?: bool}
@deprecated("Directly create record instead") @obj
external loopConfig: (~iterations: int=?, ~resetBeforeIteration: bool=?) => loopConfig = ""

// multiple externals
@module("react-native") @scope("Animated")
Expand All @@ -219,22 +219,26 @@ external loop: Animation.t => Animation.t = "loop"
@module("react-native") @scope("Animated")
external loopWithConfig: (Animation.t, loopConfig) => Animation.t = "loop"

type eventOptions<'a>
@obj
type eventOptions<'a, 'platformConfig> = {
listener?: 'a,
useNativeDriver: bool,
platformConfig?: 'platformConfig,
}
@deprecated("Directly create record instead") @obj
external eventOptions: (
~listener: 'a=?,
~useNativeDriver: bool,
~platformConfig: 'platformConfig=?,
unit,
) => eventOptions<'a> = ""
) => eventOptions<'a, 'platformConfig> = ""

// multiple externals
@module("react-native") @scope("Animated")
external event1: (array<'mapping>, eventOptions<'a>) => 'a = "event"
external event1: (array<'mapping>, eventOptions<'a, 'platformConfig>) => 'a = "event"

// multiple externals
@module("react-native") @scope("Animated")
external event2: (('mapping1, 'mapping2), eventOptions<'a>) => 'a = "event"
external event2: (('mapping1, 'mapping2), eventOptions<'a, 'platformConfig>) => 'a = "event"

@module("react-native") @scope("Animated")
external createAnimatedComponent: React.component<'props> => React.component<'props> =
Expand Down
14 changes: 9 additions & 5 deletions src/apis/AppRegistry.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ type appParameters

external asAppParameters: 'a => appParameters = "%identity"

type appConfig

@obj
type appConfig<'a> = {
appKey: string,
component?: componentProvider<'a>,
run?: appParameters => unit,
section?: bool,
}
@deprecated("Directly create record instead") @obj
external appConfig: (
~appKey: string,
~component: componentProvider<'a>=?,
~run: appParameters => unit=?,
~section: bool=?,
unit,
) => appConfig = ""
) => appConfig<'a> = ""

type runnable<'a> = {
"component": Js.Nullable.t<componentProvider<'a>>,
Expand Down Expand Up @@ -62,7 +66,7 @@ external registerComponentWithSection: (appKey, componentProvider<'a>, section)
"registerComponent"

@module("react-native") @scope("AppRegistry")
external registerConfig: array<appConfig> => unit = "registerConfig"
external registerConfig: array<appConfig<'a>> => unit = "registerConfig"

@module("react-native") @scope("AppRegistry")
external registerRunnable: (appKey, appParameters => unit) => string = "registerRunnable"
Expand Down
8 changes: 6 additions & 2 deletions src/apis/Style.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ type margin = size
@inline
let auto = "auto"

type offset
@obj external offset: (~height: float, ~width: float) => offset = ""
type offset = {
height: float,
width: float,
}
@deprecated("Directly create record instead") @obj
external offset: (~height: float, ~width: float) => offset = ""

type angle
let deg: float => angle = num => (num->Js.Float.toString ++ "deg")->Obj.magic
Expand Down
8 changes: 6 additions & 2 deletions src/apis/Style.resi
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ type margin = size
@inline("auto")
let auto: margin

type offset
@obj external offset: (~height: float, ~width: float) => offset = ""
type offset = {
height: float,
width: float,
}
@deprecated("Directly create record instead") @obj
external offset: (~height: float, ~width: float) => offset = ""

type angle
let deg: float => angle
Expand Down
5 changes: 3 additions & 2 deletions src/components/ScrollView.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include ScrollViewElement

type contentOffset
@obj external contentOffset: (~x: float, ~y: float) => contentOffset = ""
type contentOffset = {x: float, y: float}
@deprecated("Directly create record instead") @obj
external contentOffset: (~x: float, ~y: float) => contentOffset = ""

type contentInsetAdjustmentBehavior = [
| #automatic
Expand Down
27 changes: 14 additions & 13 deletions src/types/Accessibility.res
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
type state
type checked<'a> = 'a

@inline
let checked = true

@inline
let unchecked = false

@inline
let mixed = "mixed"
@unboxed
type checked =
| @as(false) False
| @as(true) True
| @as("mixed") Mixed

type actionInfo = {
name: string,
Expand All @@ -17,11 +11,18 @@ type actionInfo = {

type actionEvent = AccessibilityActionEvent.t

@obj
type state = {
disabled?: bool,
selected?: bool,
checked?: checked,
busy?: bool,
expanded?: bool,
}
@deprecated("Directly create record instead") @obj
external state: (
~disabled: bool=?,
~selected: bool=?,
~checked: checked<'a>=?,
~checked: checked=?,
~busy: bool=?,
~expanded: bool=?,
unit,
Expand Down
27 changes: 14 additions & 13 deletions src/types/Accessibility.resi
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
type state
type checked<'a>

@inline(true)
let checked: checked<bool>

@inline(false)
let unchecked: checked<bool>

@inline("mixed")
let mixed: checked<string>
@unboxed
type checked =
| @as(false) False
| @as(true) True
| @as("mixed") Mixed

type actionInfo = {
name: string,
Expand All @@ -17,11 +11,18 @@ type actionInfo = {

type actionEvent = AccessibilityActionEvent.t

@obj
type state = {
disabled?: bool,
selected?: bool,
checked?: checked,
busy?: bool,
expanded?: bool,
}
@deprecated("Directly create record instead") @obj
external state: (
~disabled: bool=?,
~selected: bool=?,
~checked: checked<'a>=?,
~checked: checked=?,
~busy: bool=?,
~expanded: bool=?,
unit,
Expand Down
Loading