From c455b0ecc3b61a84eda4c1406ca5b441907d91f4 Mon Sep 17 00:00:00 2001 From: Matthew W Date: Thu, 17 Oct 2024 15:46:56 +1100 Subject: [PATCH] fix: state type for session and channel created via factory functions defaults to unknown instead of Default[Session/Channel]State --- CHANGELOG.md | 4 ++++ src/createChannel.ts | 8 ++++++-- src/createSession.ts | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b4bf3..de8e687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +* Fixed default state type when creating sessions and channels with `createSession` and `createChannel` being set to `unknown` instead of `DefaultSessionState` and `DefaultChannelState`, respectively. + ## 0.13.0 - 2024-08-23 ### Added diff --git a/src/createChannel.ts b/src/createChannel.ts index 5918557..130c711 100644 --- a/src/createChannel.ts +++ b/src/createChannel.ts @@ -1,6 +1,10 @@ -import {Channel} from "./Channel"; +import {Channel, DefaultChannelState} from "./Channel"; +import {DefaultSessionState} from "./Session"; -const createChannel = ( +const createChannel = < + State = DefaultChannelState, + SessionState = DefaultSessionState, +>( ...args: ConstructorParameters> ): Channel => new Channel(...args); diff --git a/src/createSession.ts b/src/createSession.ts index 85018e0..9f6c26a 100644 --- a/src/createSession.ts +++ b/src/createSession.ts @@ -1,9 +1,9 @@ -import {Session} from "./Session"; +import {Session, DefaultSessionState} from "./Session"; /** * Create a new session and return the session instance once it has connected. */ -const createSession = ( +const createSession = ( ...args: ConstructorParameters> ): Promise> => new Promise((resolve) => {