pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
553 stars 401 forks source link

Can not use declaritive import without esModuleInterop #410

Closed yo1dog closed 4 days ago

yo1dog commented 1 month ago

Currently, the project-wide esModuleInterop flag must be enabled in order to import the pubnub module using declarative syntax (import * as PubNub from 'pubnub'). Alternatively, dynamic import syntax may be used (import PubNub = require('pubnub')), but that carries its own list of disadvantages.

This is fixed by simply declaring a PubNub namespace alongside the exported class like so:

declare class PubNub ...
declare namespace PubNub {}
export = PubNub;

This matches the DefinitelyTyped package: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pubnub/index.d.ts#L330

parfeon commented 3 weeks ago

@yo1dog this issue is addressed in v8.2.10