Skip to content

Commit 3c7e5a2

Browse files
authored
Add roles declarations to allow safe coercions (#175)
1 parent c09f24b commit 3c7e5a2

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/React.purs

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ foreign import data ReactComponent :: Type
9393
-- | A reference to a component, essentially React's `this`.
9494
foreign import data ReactThis :: Type -> Type -> Type
9595

96+
type role ReactThis representational representational
97+
9698
foreign import data ReactUnusedSnapshot :: Type
9799

98100
type SyntheticEventHandler event = EffectFn1 event Unit
@@ -251,6 +253,8 @@ foreign import statelessComponent :: forall props.
251253
-- | React class for components.
252254
foreign import data ReactClass :: Type -> Type
253255

256+
type role ReactClass representational
257+
254258
foreign import fragment :: ReactClass { children :: Children }
255259

256260
-- | Read the component props.

src/React/Ref.purs

+4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ foreign import data NativeNode :: Type
2727

2828
foreign import data Ref :: Type -> Type
2929

30+
type role Ref representational
31+
3032
foreign import data RefHandler :: Type -> Type
3133

34+
type role RefHandler representational
35+
3236

3337
foreign import createRef :: forall a. Effect (Ref a)
3438

src/React/SyntheticEvent.purs

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ type SyntheticWheelEvent
136136

137137
foreign import data SyntheticEvent_ :: Row Type -> Type
138138

139+
type role SyntheticEvent_ representational
140+
139141
foreign import data NativeEventTarget :: Type
140142

141143
foreign import data NativeEvent :: Type

0 commit comments

Comments
 (0)