PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
831 stars 161 forks source link

[Typescript] Could not find a declaration file for module 'react-native-collapsible-tab-view' #139

Closed sanduluca closed 3 years ago

sanduluca commented 3 years ago

I get this Typescript error and have no idea how to solve it. There is not @types/react-native-collapsible-tab-view. I see that package is written on Typescript, but I get this error. What is wrong ? How should I solve it ?

Could not find a declaration file for module 'react-native-collapsible-tab-view'. 'c:/Projects/my-app/node_modules/react-native-collapsible-tab-view/lib/commonjs/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-native-collapsible-tab-view` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native-collapsible-tab-view';`
andreialecu commented 3 years ago

Make sure to install react-native-collapsible-tab-view@next. The current stable version on npm will be deprecated soon.

sanduluca commented 3 years ago

Thank for your quick reply. I updated the package to next version and replace the default example, but now I get this error image

PedroBern commented 3 years ago

@sanduluca do you get this on v4?

sanduluca commented 3 years ago

@sanduluca do you get this on v4?

Yes.

"dependencies": {
    "...": "...",
    "react-native-collapsible-tab-view": "^4.0.0-rc.11",
    "...": "..."
}
andreialecu commented 3 years ago

@sanduluca what version of @types/react-native do you have installed?

I had to revert to "@types/react-native": "^0.62.0", in a project due to a similar error. I think something is broken in recent typing versions.

sanduluca commented 3 years ago
"devDependencies": {
    "@types/react-native": "^0.63.46",
    "@types/react": "^17.0.0"
}
andreialecu commented 3 years ago

Try changing it to the one I mentioned in the comment above and run an install again, and see if it helps (reload VSCode afterwards to make sure)

sanduluca commented 3 years ago

I've tried patch 0.62.0 and there is no error anymore. Decided to find out from what patch an error will be raised. So from patch 0.63.41 (included) there are errors with react-native typings.

andreialecu commented 3 years ago

It's been reported in other libraries:

https://github.com/callstack/react-native-paper/issues/2442

Seems it was broken here:

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49983

I'll close this since it's an upstream issue.

GermaVinsmoke commented 2 years ago

If you want to use the latest version of react-native then can add this comment on top of the <ScrollView> component - {/* @ts-ignore */}

{/*// @ts-ignore */}
<Tabs.ScrollView>
  <Text>Second page</Text>
  <Text>Second page</Text>
  <Text>Second page</Text>
</Tabs.ScrollView>

For the time being, things are not corrected, can go with this (I know it is not a good thing but still 😓)

shyambhongle commented 1 year ago

workaround without ignoring ts import {ScrollView} from 'react-native-collapsible-tab-view'; ..... <ScrollView accessibilityComponentType={undefined} accessibilityTraits={undefined}> ..... </ScrollView>