Skip to content

Commit b77a3a0

Browse files
authored
[6.x] TSLint: handle errors in kbn_internal_native_observable types. (#20708)
1 parent 2df6eed commit b77a3a0

File tree

1 file changed

+82
-86
lines changed
  • src/core/lib/kbn_internal_native_observable

1 file changed

+82
-86
lines changed

src/core/lib/kbn_internal_native_observable/index.d.ts

Lines changed: 82 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
/* tslint:disable */
19+
2020
// This adds a symbol type for `Symbol.observable`, which doesn't exist globally
2121
// in TypeScript yet.
2222
declare global {
@@ -29,111 +29,107 @@ declare global {
2929
// https://github.com/tc39/proposal-observable#api, with the addition of using
3030
// generics to define the type of the `value`.
3131

32-
declare namespace Observable {
33-
interface Subscription {
34-
// Cancels the subscription
35-
unsubscribe(): void;
32+
interface Subscription {
33+
// A boolean value indicating whether the subscription is closed
34+
closed: boolean;
3635

37-
// A boolean value indicating whether the subscription is closed
38-
closed: boolean;
39-
}
36+
// Cancels the subscription
37+
unsubscribe(): void;
38+
}
4039

41-
interface Subscribable<T> {
42-
subscribe(
43-
observerOrNext?: SubscriptionObserver<T> | ((value: T) => void),
44-
error?: (error: any) => void,
45-
complete?: () => void
46-
): Subscription;
47-
}
40+
interface Subscribable<T> {
41+
subscribe(
42+
observerOrNext?: SubscriptionObserver<T> | ((value: T) => void),
43+
error?: (error: any) => void,
44+
complete?: () => void
45+
): Subscription;
46+
}
4847

49-
type ObservableInput<T> = Subscribable<T> | Iterable<T>;
48+
type ObservableInput<T> = Subscribable<T> | Iterable<T>;
5049

51-
interface SubscriptionObserver<T> {
52-
// Sends the next value in the sequence
53-
next(value: T): void;
50+
interface SubscriptionObserver<T> {
51+
// A boolean value indicating whether the subscription is closed
52+
closed: boolean;
5453

55-
// Sends the sequence error
56-
error(errorValue: Error): void;
54+
// Sends the next value in the sequence
55+
next(value: T): void;
5756

58-
// Sends the completion notification
59-
complete(): void;
57+
// Sends the sequence error
58+
error(errorValue: Error): void;
6059

61-
// A boolean value indicating whether the subscription is closed
62-
closed: boolean;
63-
}
60+
// Sends the completion notification
61+
complete(): void;
62+
}
6463

65-
export interface StartObserver<T> {
66-
start(subscription: Subscription): void;
67-
next?(value: T): void;
68-
error?(err: any): void;
69-
complete?(): void;
70-
}
64+
export interface StartObserver<T> {
65+
start(subscription: Subscription): void;
66+
next?(value: T): void;
67+
error?(err: any): void;
68+
complete?(): void;
69+
}
7170

72-
export interface NextObserver<T> {
73-
start?(subscription: Subscription): void;
74-
next(value: T): void;
75-
error?(err: any): void;
76-
complete?(): void;
77-
}
71+
export interface NextObserver<T> {
72+
start?(subscription: Subscription): void;
73+
next(value: T): void;
74+
error?(err: any): void;
75+
complete?(): void;
76+
}
7877

79-
interface ErrorObserver<T> {
80-
start?(subscription: Subscription): void;
81-
next?(value: T): void;
82-
error(err: any): void;
83-
complete?(): void;
84-
}
78+
interface ErrorObserver<T> {
79+
start?(subscription: Subscription): void;
80+
next?(value: T): void;
81+
error(err: any): void;
82+
complete?(): void;
83+
}
8584

86-
interface CompletionObserver<T> {
87-
start?(subscription: Subscription): void;
88-
next?(value: T): void;
89-
error?(err: any): void;
90-
complete(): void;
91-
}
85+
interface CompletionObserver<T> {
86+
start?(subscription: Subscription): void;
87+
next?(value: T): void;
88+
error?(err: any): void;
89+
complete(): void;
90+
}
9291

93-
type PartialObserver<T> =
94-
| StartObserver<T>
95-
| NextObserver<T>
96-
| ErrorObserver<T>
97-
| CompletionObserver<T>;
92+
type PartialObserver<T> =
93+
| StartObserver<T>
94+
| NextObserver<T>
95+
| ErrorObserver<T>
96+
| CompletionObserver<T>;
9897

99-
interface Observer<T> {
100-
// Receives the subscription object when `subscribe` is called
101-
start(subscription: Subscription): void;
98+
interface Observer<T> {
99+
// Receives the subscription object when `subscribe` is called
100+
start(subscription: Subscription): void;
102101

103-
// Receives the next value in the sequence
104-
next(value: T): void;
102+
// Receives the next value in the sequence
103+
next(value: T): void;
105104

106-
// Receives the sequence error
107-
error(errorValue: Error): void;
105+
// Receives the sequence error
106+
error(errorValue: Error): void;
108107

109-
// Receives a completion notification
110-
complete(): void;
111-
}
108+
// Receives a completion notification
109+
complete(): void;
110+
}
112111

113-
type SubscriberFunction<T> = (
114-
observer: SubscriptionObserver<T>
115-
) => void | null | undefined | (() => void) | Subscription;
112+
type SubscriberFunction<T> = (
113+
observer: SubscriptionObserver<T>
114+
) => void | null | undefined | (() => void) | Subscription;
116115

117-
class Observable<T> {
118-
constructor(subscriber: SubscriberFunction<T>);
116+
export class Observable<T> {
117+
public static of<T>(...items: T[]): Observable<T>;
118+
public static from<T>(x: ObservableInput<T>): Observable<T>;
119119

120-
// Subscribes to the sequence with an observer
121-
subscribe(): Subscription;
122-
subscribe(observer: PartialObserver<T>): Subscription;
120+
constructor(subscriber: SubscriberFunction<T>);
123121

124-
// Subscribes to the sequence with callbacks
125-
subscribe(
126-
onNext: (val: T) => void,
127-
onError?: (err: Error) => void,
128-
onComplete?: () => void
129-
): Subscription;
122+
// Subscribes to the sequence with an observer
123+
public subscribe(): Subscription;
124+
public subscribe(observer: PartialObserver<T>): Subscription;
130125

131-
// Returns itself
132-
[Symbol.observable](): Observable<T>;
126+
// Subscribes to the sequence with callbacks
127+
public subscribe(
128+
onNext: (val: T) => void,
129+
onError?: (err: Error) => void,
130+
onComplete?: () => void
131+
): Subscription;
133132

134-
static of<T>(...items: T[]): Observable<T>;
135-
static from<T>(x: ObservableInput<T>): Observable<T>;
136-
}
133+
// Returns itself
134+
public [Symbol.observable](): Observable<T>;
137135
}
138-
139-
export = Observable;

0 commit comments

Comments
 (0)