Skip to content

Conversation

@tsnobip
Copy link
Contributor

@tsnobip tsnobip commented Sep 15, 2023

I worked on removing the unsafe operations as much as possible.

This would allow us to track bugs like the one that got fixed by #141.

It is a breaking change given I removed the unsafe makeRenderer and replaced it by a simple record with an optional field for prepareCode. Though I believe removing those layers of "unsafe magic" is worth it.

Let me know what you think.

ps. I didn't touch the LSP support at all, so it might need some love.

@tsnobip tsnobip force-pushed the simplify_prop_types branch from 600c6d6 to d41c8f9 Compare September 15, 2023 15:13
Comment on lines -523 to +506
let loadRouteRenderer = () => (() => Js.import(${routeName}_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers)
let loadRouteRenderer = () => (() => Js.import(${routeName}_route_renderer.renderer))->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the main Obj.magic that got removed

Comment on lines -504 to -509
str.contents ++ `@obj
external makeRenderer: (
~prepare: Internal.prepareProps => 'prepared,
~prepareCode: Internal.prepareProps => array<RelayRouter.Types.preloadAsset>=?,
~render: Internal.renderProps<'prepared> => React.element,
) => Internal.renderers<'prepared> = ""`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also removed this @obj external that could become out of sync with its underlying type

Comment on lines -138 to -139
external unsafe_toPrepareProps: 'any => prepareProps = "%identity"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced it with a safer:

external unsafe_toPrepareProps: prepareProps<'a> => prepareProps<'b> = "%identity"

in RelayRouter__Internal__DeclarationsSupport.res

@tsnobip tsnobip force-pushed the simplify_prop_types branch from d41c8f9 to 4ac6dfb Compare September 15, 2023 15:20
also made unsafe_toPrepareProps safer
removed unsafe makeRenderer
@tsnobip tsnobip force-pushed the simplify_prop_types branch from 4ac6dfb to 0ec4a8a Compare September 15, 2023 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant