Skip to content

class are being removed when migrating .re to .res #5104

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

Closed
3 of 6 tasks
MoOx opened this issue May 3, 2021 · 3 comments
Closed
3 of 6 tasks

class are being removed when migrating .re to .res #5104

MoOx opened this issue May 3, 2021 · 3 comments

Comments

@MoOx
Copy link
Contributor

MoOx commented May 3, 2021

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
    • Ideally in OCaml syntax for now. To isolate the problem caused by either Reason or the New Syntax.
  • OS and browser versions, if relevant.
  • Is it already fixed in master?

How to reproduce?

Use this

class type virtual materialTopTabBarProps = {
    as 'self;
    constraint 'self = #materialTopTabBarOptions;
    pub state: navigationState(M.params);
    pub navigation: navigation;
    pub descriptors: descriptors;
    // SceneRendererProps from react-native-tab-view
    pub layout: layout;
    pub position: animatedNode;
    pub jumpTo: string => unit;
  };

Try using bsc -format. The code just disappear. You can reproduce on the playground too (select .RE, paste the snippet, click on .RES, no more class).

This is a problem for rescript-react-navigation as we have a lot of class to bind.

MoOx added a commit to rescript-react-native/rescript-react-navigation that referenced this issue May 3, 2021
@flash-gordon
Copy link

Support for ocaml style classes was removed in 9.1. I wonder if they are truly necessary for the bindings, though.

@bobzhang
Copy link
Member

bobzhang commented May 3, 2021

hi @MoOx technically we did not remove class types, it is not exposed in rescript syntax though, so you don't need rush to convert such piece of code if you are busy, but you are suggested to migrate away from class types later.

Note in the latest release, you can compose structural types using object types (without need class types)

type small = {
   "x" : int 
}
type big = {
   ... small, "y" : int
}

let me know if you find something not expressible using object types

@bobzhang bobzhang closed this as completed May 3, 2021
@MoOx
Copy link
Contributor Author

MoOx commented May 3, 2021

To be honest, I don't see any real reason to use class. I will just convert to record and use @send if necessary.

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

No branches or pull requests

3 participants