Skip to content

Commit 4433ef0

Browse files
committed
Add roles declarations to allow safe coercions
1 parent 4bf5a5a commit 4433ef0

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
@@ -249,6 +251,8 @@ foreign import statelessComponent :: forall props.
249251
-- | React class for components.
250252
foreign import data ReactClass :: Type -> Type
251253

254+
type role ReactClass representational
255+
252256
foreign import fragment :: ReactClass { children :: Children }
253257

254258
-- | 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
@@ -135,6 +135,8 @@ type SyntheticWheelEvent
135135

136136
foreign import data SyntheticEvent_ :: # Type -> Type
137137

138+
type role SyntheticEvent_ representational
139+
138140
foreign import data NativeEventTarget :: Type
139141

140142
foreign import data NativeEvent :: Type

0 commit comments

Comments
 (0)