mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Add regression test
This commit is contained in:
parent
1a28fd0d9f
commit
228b727ff1
22
tests/cases/compiler/observableInferenceCanBeMade.ts
Normal file
22
tests/cases/compiler/observableInferenceCanBeMade.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// @strict: true
|
||||
|
||||
// Repro from #33131
|
||||
|
||||
declare function of<T>(a: T): Observable<T>;
|
||||
declare function from<O extends ObservableInput<any>>(input: O): Observable<ObservedValueOf<O>>;
|
||||
|
||||
type ObservedValueOf<O> = O extends ObservableInput<infer T> ? T : never;
|
||||
|
||||
interface Subscribable<T> {
|
||||
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): void;
|
||||
}
|
||||
type ObservableInput<T> = Subscribable<T> | Subscribable<never>;
|
||||
|
||||
|
||||
declare class Observable<T> implements Subscribable<T> {
|
||||
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): void;
|
||||
}
|
||||
|
||||
function asObservable(input: string | ObservableInput<string>): Observable<string> {
|
||||
return typeof input === 'string' ? of(input) : from(input)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user