Closed yo1dog closed 4 days ago
Created a script which will merge all type definitions created by tsc
into a single file.
Common types (for whole library) part of the root PubNub
namespace and specific API grouped under respective nested namespaces.
import PubNub, {PubNubConfiguration, Publish, History} from 'pubnub';
// PubNub client configuration.
let configuration: PubNubConfiguration = {
publishKey: 'secret',
subscribeKey: 'secret',
userId: 'user-1'
};
// Fetch messages configuration.
let fetchParameter: History.FetchMessagesParameters = {
channels: ['channel-1']
};
To import types, one must import them from module subpaths. This ties projects to the module's internal file structure, which is against best practices, and could make any internal file renaming/restructuring a breaking change.
Instead, you could expose the types from the module root using a namespace as described in https://github.com/pubnub/javascript/issues/410.
For example, currently one must:
Using the namespace you could instead do:
Or, keeping the types namespaced: