Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Typed wrapping of Js values. #60

Merged
merged 8 commits into from
Oct 12, 2018
Merged

Typed wrapping of Js values. #60

merged 8 commits into from
Oct 12, 2018

Conversation

cristianoc
Copy link
Collaborator

Experimental feature supporting typed wrappers for JS values.
Uses a controlled form of cyclic dependencies between the .bs.js and .re.js/.tsx files.
Generates conversion functions as well as type checking functions with comments indicating where to look in order to resolve type inconsistencies.

A small demo: https://youtu.be/9YeOwMmXGfo

Mock up generated filed that wrap JS functions.
Add a new annotation to test typed wrappings of JS values.
These new wrappers go in the opposite direction than the other ones, and require the generated (.re.js/.tsx) file to call the bucklescript (.bs.js) file.
This implies circular dependencies between these two pairs of files. A special category of early requires and exports is reserved to emit all the requires from .re.js/.tsx to .bs.js early. In this way, when these wrappers are used in the .bs.js file, they will have been exported already.
Changed import logic: TS uses import {... as ...}, Flow uses require.
Add a more complex example also involving a conversion of record types.
@cristianoc cristianoc merged commit 501cb91 into master Oct 12, 2018
@cristianoc cristianoc deleted the wrap_js_functions branch October 12, 2018 12:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant