Skip to content

Can not use declaritive import without esModuleInterop #410

@yo1dog

Description

@yo1dog

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

Metadata

Metadata

Assignees

Labels

priority: mediumThis PR should be reviewed after all high priority PRs.status: in progressThis issue is being worked on.type: choreThis PR contains changes that are not covered by other types (stylistic, dependency updates, etc).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions