Migrate from JavaScript SDK 7.x.x to 8.x.x
This guide upgrades a TypeScript project from the PubNub JavaScript SDK 7.x.x to 8.x.x by removing the @types/pubnub package and importing SDK types from API group namespaces. Upgrade to SDK version 8.2.10 or later, because the namespaces are available from that version. The latest version is 13.1.3.
Only code that references SDK types directly, for example in function arguments or variables, needs changes. Method calls work as they did in 7.x.x.
Remove the @types/pubnub package
Remove @types/pubnub from your project's dependencies. The SDK package ships its own type definitions, so the separate package is no longer needed.
Import types from the API group namespace
If your code imports an endpoint type such as GetMembershipsParameters directly from pubnub, import the namespace that groups the type and reference the type through it. If you are not sure which group owns a type, check the type location that your IDE suggests.
- Before (7.x.x)
- After (8.x.x)
import PubNub, { GetMembershipsParameters } from 'pubnub'
// other code
const params: GetMembershipsParameters = {};
These API group namespaces exist as of 8.2.10:
SubscriptionAppContextChannelGroupsPublishSignalPresenceHistoryMessageActionFileSharingPAMTimePush
Related tasks
- Set up your JavaScript environment. Install the SDK and configure TypeScript.