Skip to content

Commit 5317212

Browse files
author
Sergei Orlov
authored
Merge pull request #7 from Raini-js/dev
fix(default export): add backwards compatibility
2 parents c3caaa5 + bbe1388 commit 5317212

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Switch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class SwitchMatched<T, K> implements ISwitch<T, K> {
2626
* Switch becomes a kind of Left and holds the value until it reaches the .default call. If
2727
* matching didn't happen for all cases, the value of the .default argument is returned instead.
2828
*/
29-
export class Switch<T, K extends []> implements ISwitch<T, K> {
29+
export class Switch<T, K extends any[]> implements ISwitch<T, K> {
3030
/**
3131
* Pointer interface for lifting a value into Switch.
3232
*/
33-
public static for<T, K extends [] = []>(x: T): ISwitch<T, K> {
34-
return new Switch<T, K>(x);
33+
public static for<T, K = []>(x: T): ISwitch<T, K extends [] ? K : [K]> {
34+
return new Switch<T, K extends [] ? K : [K]>(x);
3535
}
3636

3737
/**

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export * from "./TPredicateFunction";
99
/**
1010
* Pointer interface for lifting value provided as an argument to Switch.
1111
*/
12-
export default function<T, K extends []>(x: T): ISwitch<T, K> {
12+
export default function test<T, K = []>(x: T): ISwitch<T, K extends [] ? K : [K]> {
1313
return Switch.for<T, K>(x);
1414
}

0 commit comments

Comments
 (0)