Skip to content

Commit c455b0e

Browse files
committed
fix: state type for session and channel created via factory functions defaults to unknown instead of Default[Session/Channel]State
1 parent 61adebd commit c455b0e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
12+
* Fixed default state type when creating sessions and channels with `createSession` and `createChannel` being set to `unknown` instead of `DefaultSessionState` and `DefaultChannelState`, respectively.
13+
1014
## 0.13.0 - 2024-08-23
1115

1216
### Added

src/createChannel.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import {Channel} from "./Channel";
1+
import {Channel, DefaultChannelState} from "./Channel";
2+
import {DefaultSessionState} from "./Session";
23

3-
const createChannel = <State, SessionState>(
4+
const createChannel = <
5+
State = DefaultChannelState,
6+
SessionState = DefaultSessionState,
7+
>(
48
...args: ConstructorParameters<typeof Channel<State, SessionState>>
59
): Channel<State, SessionState> => new Channel<State, SessionState>(...args);
610

src/createSession.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {Session} from "./Session";
1+
import {Session, DefaultSessionState} from "./Session";
22

33
/**
44
* Create a new session and return the session instance once it has connected.
55
*/
6-
const createSession = <State>(
6+
const createSession = <State = DefaultSessionState>(
77
...args: ConstructorParameters<typeof Session<State>>
88
): Promise<Session<State>> =>
99
new Promise((resolve) => {

0 commit comments

Comments
 (0)