-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ObservedValueUnion/TupleFromArray (#5254)
* feat: add observed value union and tuple types * chore: rename to use observed value union type * chore: tweak test to make dtslint deterministic For some reason, the number[] type shows up in seemingly random places in the union.
- Loading branch information
Showing
6 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
Observable, | ||
ObservedValueOf, | ||
ObservedValueUnionFromArray, | ||
ObservedValueTupleFromArray, | ||
Unshift | ||
} from 'rxjs'; | ||
import { A, B, C } from './helpers'; | ||
|
||
describe('ObservedValueOf', () => { | ||
it('should infer from an observable', () => { | ||
let explicit: ObservedValueOf<Observable<A>>; | ||
let inferred = explicit!; // $ExpectType A | ||
}); | ||
|
||
it('should infer from an array', () => { | ||
let explicit: ObservedValueOf<A[]>; | ||
let inferred = explicit!; // $ExpectType A | ||
}); | ||
|
||
it('should infer from a promise', () => { | ||
let explicit: ObservedValueOf<Promise<A>>; | ||
let inferred = explicit!; // $ExpectType A | ||
}); | ||
}); | ||
|
||
describe('ObservedUnionFromArray', () => { | ||
it('should infer from an array of observables', () => { | ||
let explicit: ObservedValueUnionFromArray<[Observable<A>, Observable<B>]>; | ||
let inferred = explicit!; // $ExpectType A | B | ||
}); | ||
|
||
it('should infer from an array of arrays', () => { | ||
let explicit: ObservedValueUnionFromArray<[A[], B[]]>; | ||
let inferred = explicit!; // $ExpectType A | B | ||
}); | ||
|
||
it('should infer from an array of promises', () => { | ||
let explicit: ObservedValueUnionFromArray<[Promise<A>, Promise<B>]>; | ||
let inferred = explicit!; // $ExpectType A | B | ||
}); | ||
}); | ||
|
||
describe('ObservedTupleFromArray', () => { | ||
it('should infer from an array of observables', () => { | ||
let explicit: ObservedValueTupleFromArray<[Observable<A>, Observable<B>]>; | ||
let inferred = explicit!; // $ExpectType [A, B] | ||
}); | ||
|
||
it('should infer from an array of arrays', () => { | ||
let explicit: ObservedValueTupleFromArray<[A[], B[]]>; | ||
let inferred = explicit!; // $ExpectType [A, B] | ||
}); | ||
|
||
it('should infer from an array of promises', () => { | ||
let explicit: ObservedValueTupleFromArray<[Promise<A>, Promise<B>]>; | ||
let inferred = explicit!; // $ExpectType [A, B] | ||
}); | ||
}); | ||
|
||
describe('Unshift', () => { | ||
it('should add the type to the beginning of the tuple', () => { | ||
let tuple: ObservedValueTupleFromArray<[Observable<A>, Observable<B>]>; | ||
let explicit: Unshift<typeof tuple, C>; | ||
let inferred = explicit!; // $ExpectType [C, A, B] | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters