DefinitelyTyped / DefinitelyTyped

The repository for high quality TypeScript type definitions.
Other
48.39k stars 30.12k forks source link

[@types/react-native-calendars] Version conflict with @types/react-native #51124

Open osartun opened 3 years ago

osartun commented 3 years ago

After upgrading the @types/react-native package to 0.63.45 I get issues with the ViewStyle prop being in conflict with the ViewStyle prop defined in the @types/react-native version that @types/react-native-calendars uses.

Type 'import("…/node_modules/@types/react-native/index").StyleProp<import("…/node_modules/@types/react-native/index").ViewStyle>' is not assignable to type 'import("…/node_modules/@types/react-native-calendars/node_modules/@types/react-native/index").StyleProp<import("…/node_modules/@types/react-native-calendars/node_modules/@types/react-native/index").ViewStyle>'.
  Type 'ViewStyle' is not assignable to type 'StyleProp<ViewStyle>'.
    Type 'import("…/node_modules/@types/react-native/index").ViewStyle' is not assignable to type 'import("…/node_modules/@types/react-native-calendars/node_modules/@types/react-native/index").ViewStyle'.
      Types of property 'backgroundColor' are incompatible.
        Type 'string | unique symbol | undefined' is not assignable to type 'string | undefined'.
          Type 'unique symbol' is not assignable to type 'string | undefined'.

Type 'import("…/@types/react-native/index").ViewStyle' is not assignable to type 'import("…/@types/react-native-calendars/node_modules/@types/react-native/index").ViewStyle'.

The problem is that @types/react-native-calendars defines "@types/react-native": "*" as a dependency. Yarn resolves that wildcard dependency to version 0.60.7 which has a different ViewStyle definition than 0.63.45.

You could think of this as a Yarn issue. However, it was already addressed in an issue in the Yarn repo (https://github.com/yarnpkg/yarn/issues/6695) and they say that it's not on their end. Instead, they say those "dependencies" should be "peerDependencies" (https://github.com/yarnpkg/yarn/issues/6695#issuecomment-439870884). Unfortunately, there's not even a package.json in the react-native-calendars types folder where I could make such a change. Idk how this DefinitelyTyped repo works / where those dependencies are being defined and where the package.json is being generated. Apparently, changing "dependencies" to "peerDependencies" has been discussed before (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20290), seemingly without any resolution.

I also tried yarn's "resolutions" field in the package.json to make sure that only one version of @types/react-native is installed. But to no avail.

So, I'm creating this issue to bring attention to it and because I haven't seen this exact issue in this repo yet.

tomasswood commented 3 years ago

Doing my resolution like this appears to have resolved the issue:

  "resolutions": {
    "@types/**/@types/react-native": "0.64.10"
  }
osartun commented 3 years ago

@tomasswood Thank you so much! I tried it out and it works! ✨