JavaScript SDK 8.0.0 migration guide
The 8.0.0 release of the JavaScript SDK removes the need to have a dependency on the @types/pubnub
package and introduces said types as part of the SDK package.
Although we tried to keep the API surface compatible with the 7.X.X release, you must make a few changes in your application code when migrating to the JavaScript SDK in version 8.0.0.
This guide provides an overview of all the differences between the two versions and documents the steps you need to follow to migrate to JavaScript SDK in version 8.0.0.
Differences between 7.x.x
and 8.0.0
See all the major differences between the two versions:
Feature/Method/Field/Package | JavaScript SDK 7.x.x | JavaScript SDK 8.x.x |
---|---|---|
@types/pubnub package dependency | Yes | No, must be removed |
API group names in imports | N/A | Yes |
@types/pubnub dependency
The need for the @types/pubnub
dependency has been removed from the JavaScript SDK v.8.0.0 and you must remove it from your project. The PubNub SDK package now provides its own types without the need for any external dependencies.
Affected types
The dependency change will only affect your code if you use the types directly, by specifying them in the function argument types or variables.
Endpoint-related types have been moved to their corresponding endpoint namespaces. The types have been grouped by the API they logically belong to. You can check how the APIs are grouped in the documentation's sidebar, and your IDE should also be able to provide hints about the types' locations.
JavaScript SDK 7.x.x
import PubNub, { GetMembershipsParameters } from 'pubnub'
// other code
const params: GetMembershipsParameters = {};
JavaScript SDK 8.x.x
import PubNub, { AppContext } from 'pubnub'
// other code
const params: AppContext.GetMembershipsParameters = {};
Available API endpoint groups are as follows:
Subscription
AppContext
ChannelGroup
Publish
Signal
Presence
History
MessageAction
FileSharing
PAM
Time
Push
To migrate from JavaScript SDK v.7.0.0 to v.8.0.0, perform the following steps:
-
Remove the dependency to
@pubnub/types
. -
Inspect the code and change the import statements for PubNub types to reflect the endpoint groups the types belong to.
Migration steps
To migrate from the JavaScript SDK version 7.x.x
to 8.0.0
, upgrade the SDK version in your project, inspect the differences listed in the table above, and change your code accordingly.