buildo / react-cookie-banner

React Cookie banner which can be automatically dismissed with a scroll. Because fuck The Cookie Law, that's why.
http://react-components.buildo.io/#cookiebanner
MIT License
182 stars 19 forks source link

Typings problem with 2.0.0 #44

Closed PeterKottas closed 6 years ago

PeterKottas commented 6 years ago

Hi, I've updated to the recent version and now I am seeing this error:

ERROR in [at-loader] ./node_modules/react-cookie-banner/lib/CookieBanner.d.ts:4:10 TS2305: Module ''react-cookie'' has no exported member 'Cookies'. ERROR in [at-loader] ./node_modules/react-cookie-banner/lib/index.d.ts:5:10 TS2305: Module ''react-cookie'' has no exported member 'Cookies'.

Seems simple enough to fix, I reverted to the previous version for now.

FrancescoCioria commented 6 years ago

Mmm, the react-cookie typings are defined in typings/react-cookie.d.ts inside the package and TS should use them by default.

Do you have that file in your package inside your node_modules?

FrancescoCioria commented 6 years ago

Are you sure you don't have declared some custom typings for react-cookie-banenr in your project? like in a react-cookie-banner.d.ts file inside your /typings?

PeterKottas commented 6 years ago

Hi there, nah I am positive I don't have typing declared for react-cookie-banner. I have in fact declared typings for react-cookie as they are not provided by that package. But these are not take into consideration. In fact let me provide some screenshots to make things clearer.

PeterKottas commented 6 years ago

cookiebanner index So the import resolves to index.js in 'react-cookie' which has no typings and apparently it uses that file to generate some static types (I am guessing here).

PeterKottas commented 6 years ago

package.json: "react-cookie": "2.1.2", "react-cookie-banner": "2.0.0", "typescript": "2.6.2", And I am using webpack 3.10.0 to build this

FrancescoCioria commented 6 years ago

I have in fact declared typings for react-cookie as they are not provided by that package

This could be the issue: your typings may be overriding the ones declared by react-cookie-banner in react-cookie-banner/typings/react-cookie.d.ts.

In your declaration did you define the class Cookies and are you exporting it?

This is the typings we made for react-cookie: https://github.com/buildo/react-cookie-banner/blob/master/typings/react-cookie.d.ts

PeterKottas commented 6 years ago

Ok you're right, mine was slightly different but all sorted now. One thing though, you might want to look at https://github.com/reactivestack/cookies/pull/124, these are typings I've written originally and they seem to be going into the lib. It might be worth keeping an eye on it and disable yours when this is merged as there might be clashes like this for other people as well. Especially if they change something. Thanks for the help mate ;)

PeterKottas commented 6 years ago

Oh and thanks for the lib, it's quite useful ;)

FrancescoCioria commented 6 years ago

One thing though, you might want to look at reactivestack/cookies#124

Yes, I copied them from the linked issue and changed them just a little. I'll open an issue to follow that!

Thanks for the help mate ;)

You're welcome :)