rescript-react-native / rescript-react-navigation

ReScript bindings for React Navigation
MIT License
72 stars 30 forks source link

Syntax errors compiling version 6 #49

Closed kodeFant closed 2 years ago

kodeFant commented 2 years ago

Hi :)

First of all, thanks a lot for maintaining the rescript-react-native ecosystem! I'm looking into it now in hopes of a more type-safe way to make RN apps. It seems super promising, and seems to have most of the bindings I need 🥇

I am having an issue compiling a working rescript-react-native project with the rescript-react-navigation bindings.

Here is a minimal reproducible repo, based on an expo starter: https://github.com/kodeFant/rescript-react-navigation-issue

I have tried to lock every version to version 6.0.0 to be sure it's all aligned, but does not seem to help.

When I try to run npm run re:clean-build, I get this error message:

Dependency on rescript-react-navigation
bsb: [2/37] src/Drawer.ast
FAILED: src/Drawer.ast

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:65:5-7

  63 ┆ 
  64 ┆ type drawerNavigationItemsProps = {
  65 ┆   ...contentOptions,
  66 ┆   "drawerPosition": string,
  67 ┆   "getLabel": scene => React.element,

  I'm not sure what to parse here when looking at "...".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:66:21

  64 ┆ type drawerNavigationItemsProps = {
  65 ┆   ...contentOptions,
  66 ┆   "drawerPosition": string,
  67 ┆   "getLabel": scene => React.element,
  68 ┆   "renderIcon": scene => React.element,

  I'm not sure what to parse here when looking at ":".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:73:5-7

  71 ┆ 
  72 ┆ type contentComponentProps = {
  73 ┆   ...drawerNavigationItemsProps,
  74 ┆   "navigation": navigation,
  75 ┆   "drawerOpenProgress": animatedNode,

  I'm not sure what to parse here when looking at "...".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:74:17

  72 ┆ type contentComponentProps = {
  73 ┆   ...drawerNavigationItemsProps,
  74 ┆   "navigation": navigation,
  75 ┆   "drawerOpenProgress": animatedNode,
  76 ┆ }

  I'm not sure what to parse here when looking at ":".

bsb: [8/37] src/BottomTabs.ast
FAILED: src/BottomTabs.ast

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:55:5-7

  53 ┆ 
  54 ┆ type bottomTabBarOptions = {
  55 ┆   ...baseBottomTabBarOptions,
  56 ┆   "activeTintColor": option<string>,
  57 ┆   "inactiveTintColor": option<string>,

  I'm not sure what to parse here when looking at "...".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:56:22

  54 ┆ type bottomTabBarOptions = {
  55 ┆   ...baseBottomTabBarOptions,
  56 ┆   "activeTintColor": option<string>,
  57 ┆   "inactiveTintColor": option<string>,
  58 ┆ }

  I'm not sure what to parse here when looking at ":".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:71:5-7

  69 ┆ 
  70 ┆ type bottomTabBarProps = {
  71 ┆   ...baseBottomTabBarOptions,
  72 ┆   "state": navigationState<M.params>,
  73 ┆   "navigation": navigation,

  I'm not sure what to parse here when looking at "...".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:72:12

  70 ┆ type bottomTabBarProps = {
  71 ┆   ...baseBottomTabBarOptions,
  72 ┆   "state": navigationState<M.params>,
  73 ┆   "navigation": navigation,
  74 ┆   "onTabPress": routeArgs => unit,

  I'm not sure what to parse here when looking at ":".

bsb: [10/37] src/MaterialTopTabs.ast
FAILED: src/MaterialTopTabs.ast

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:60:5-7

  58 ┆ 
  59 ┆ type materialTopTabBarOptions = {
  60 ┆   ...tabBar,
  61 ┆   "activeTintColor": option<string>,
  62 ┆   "inactiveTintColor": option<string>,

  I'm not sure what to parse here when looking at "...".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:61:22

  59 ┆ type materialTopTabBarOptions = {
  60 ┆   ...tabBar,
  61 ┆   "activeTintColor": option<string>,
  62 ┆   "inactiveTintColor": option<string>,
  63 ┆   "iconStyle": option<ReactNative.Style.t>,

  I'm not sure what to parse here when looking at ":".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:94:5-7

  92 ┆ 
  93 ┆ type materialTopTabBarProps = {
  94 ┆   ...materialTopTabBarOptions,
  95 ┆   "state": navigationState<M.params>,
  96 ┆   "navigation": navigation,

  I'm not sure what to parse here when looking at "...".

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:95:12

  93 ┆ type materialTopTabBarProps = {
  94 ┆   ...materialTopTabBarOptions,
  95 ┆   "state": navigationState<M.params>,
  96 ┆   "navigation": navigation,
  97 ┆   "descriptors": descriptors,

  I'm not sure what to parse here when looking at ":".

bsb: [31/37] src/Example-ReactNavigation.cmj
FAILED: cannot make progress due to previous errors.
Failure: /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/bs-platform/darwin/ninja.exe 
Location: /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/lib/bs
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ re:clean-build: `bsb -clean-world -make-world`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @ re:clean-build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/larslilloulvestad/.npm/_logs/2021-12-08T03_08_09_505Z-debug.log
kodeFant commented 2 years ago

Ah! After looking into bsb, I found that switching out bsb scripts with rescript scripts solved the problem.

Switching out these

  "scripts": {
    ...
    "re:build": "bsb -make-world",
    "re:watch": "bsb -make-world -w",
    "re:clean": "bsb -clean-world",
    "re:clean-build": "bsb -clean-world -make-world"
  },

for these

  "scripts": {
    ...
    "re:build": "rescript build",
    "re:watch": "rescript build -w",
    "re:clean": "rescript clean"
  },

seems to have done the trick 👍

MoOx commented 2 years ago

Glad you this is now working for you!