Skip to content

Commit

Permalink
fix: state type for session and channel created via factory functions…
Browse files Browse the repository at this point in the history
… defaults to unknown instead of Default[Session/Channel]State
  • Loading branch information
MatthewWid committed Oct 17, 2024
1 parent 61adebd commit c455b0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/createChannel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {Channel} from "./Channel";
import {Channel, DefaultChannelState} from "./Channel";
import {DefaultSessionState} from "./Session";

const createChannel = <State, SessionState>(
const createChannel = <
State = DefaultChannelState,
SessionState = DefaultSessionState,
>(
...args: ConstructorParameters<typeof Channel<State, SessionState>>
): Channel<State, SessionState> => new Channel<State, SessionState>(...args);

Expand Down
4 changes: 2 additions & 2 deletions src/createSession.ts
Original file line number Diff line number Diff line change
@@ -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 = <State>(
const createSession = <State = DefaultSessionState>(
...args: ConstructorParameters<typeof Session<State>>
): Promise<Session<State>> =>
new Promise((resolve) => {
Expand Down

0 comments on commit c455b0e

Please sign in to comment.