mmazzarolo / react-native-universal-monorepo

React Native boilerplate supporting multiple platforms: Android, iOS, macOS, Windows, web, browser extensions, Electron.
MIT License
1.7k stars 150 forks source link

Typescript errors in node_modules #27

Closed ericlifs closed 2 years ago

ericlifs commented 2 years ago

Hey everyone! I'm porting my current monorepo to this awesome setup and I'm facing some new issues that I didn't have before. I have some 3rd party libraries installed in my repo and I'm getting some errors on those libraries' code that I didn't have before.

The thing is that even though I have my node_modules folder excluded from transpiling within my tsconfig.json file (the same way you did), I'm still getting typescript errors from those libraries.

You can replicate this issue just by cloning your repo and installing react-native-linear-gradient or react-native-dialog in the app package, add some usage in the App.tsx file and then start the web package. You will see something like:

image image image image image

I don't know if I have to configure babel in a certain way in order to make this error disappear, but my previous monorepo was also using a CRA scaffold for the web package and I was not getting any of this errors.

Thank you very much,

Eric.

ericlifs commented 2 years ago

I have just tested this again starting from scratch on your monorepo scaffold and I'm seeing the same issues. For example if you want to install react-native-linear-gradient for the web you need to:

webpack: {
    alias: {
      'react-native-linear-gradient': 'react-native-web-linear-gradient',
    },
    ...
}
<LinearGradient colors={['#4c669f', '#3b5998', '#192f6a']} style={styles.linearGradient}>
  <Text style={styles.buttonText}>
    Sign in with Facebook
  </Text>
</LinearGradient>
linearGradient: {
    flex: 1,
    paddingLeft: 15,
    paddingRight: 15,
    borderRadius: 5
  },
  buttonText: {
    fontSize: 18,
    fontFamily: 'Gill Sans',
    textAlign: 'center',
    margin: 10,
    color: '#ffffff',
    backgroundColor: 'transparent',
  },
image

I'm not sure if this is something that has happened in the past.

Thanks,

Eric.

mmazzarolo commented 2 years ago

@ericlifs sorry for being late, I'm busy these days. Can you try following the same flow we're using with the @react-native-async-storage/async-storage package? It's a native module as well, so I would expect react-native-linear-gradient to work in the same way.