Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module '"pusher-js"' has no exported member 'Config' #25

Closed
snaptopixel opened this issue Jun 9, 2020 · 6 comments
Closed

Module '"pusher-js"' has no exported member 'Config' #25

snaptopixel opened this issue Jun 9, 2020 · 6 comments

Comments

@snaptopixel
Copy link

Using Typescript with these versions will not compile:

"pusher-js": "^6.0.3",
"pusher-js-mock": "^0.3.1",

Pusher mock's types specify: import { Config } from "pusher-js"; but Config is not exported in this version of pusher-js

@snaptopixel
Copy link
Author

FWIW, I got around this for now… (I'm using .ts files for tests)

import Pusher from 'pusher-js'
const PusherMock = require('pusher-js-mock').PusherMock
const pusher = new PusherMock() as Pusher

@nikolalsvk
Copy link
Owner

Hey, @snaptopixel, thanks for creating an issue about this!

@mayteio can you help out on this one? I see that the Config has been changed to Option and I'm not sure whether we should support custom authorization at this point. I feel like this is something that should be tested outside this library, it is adding too much complexity, what do you think?

@mayteio
Copy link
Contributor

mayteio commented Jun 16, 2020

Hey @nikolalsvk, if you want to roll back to drop support for custom authorization that's your call. Personally I feel the package should replicate the real thing as much as possible, which is what I was trying to achieve with custom auth (we used custom auth in our project thus the need to mock it).

If it's a simple case of switching the Config type to Option surely that's something we can do here?

@nikolalsvk
Copy link
Owner

Thanks for responding, @mayteio. Do you think we could achieve a similar thing without being dependant on the pusher-js?

For example, can we try to support custom authorization without import Config or Option? This will allow for easier support of previous and new versions of the pusher-js.

@mayteio
Copy link
Contributor

mayteio commented Jun 23, 2020

OK, so this problem is because pusher-js released official types that are incompatible with @types/pusher-js (that was the only option available for typescript when presence channel work was being done).

It gives to reason that if someone is using pusher-js-mock to test their app they have pusher-js as a dependency too, so I don't think it's farfetched to rely on it.

A good example is in the 'presence-channel' example where the official pusher-js is being mocked by jest.

I've created #29 to remove the @types/pusher-js dependency, update the pusher-js dependency from 4.2.2 to 6.0.3 and fix relevant imports. I added any types to some of the tests to make them pass. In reality (according to the types) the following test is actually an invalid case and should never happen:

https://github.com/mayteio/pusher-js-mock/blob/dbbfb8c4079c4f54585f8f1e50e173684fec2080/src/__tests__/pusher-js-mock.spec.ts#L184-L191

This test case can be removed in future versions.

It's probably worth noting that the project relies on itself via the examples. The examples should probably have their own package.json to avoid this.

@nikolalsvk
Copy link
Owner

This should not happen now with the new 0.3.2 version. Can you check @snaptopixel when you have time? I'll close this in the meantime and reopen if it's not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants