Closed
Description
TypeScript Version:
1.8.10
Code
node_modules/module1/test.example.ts
import {
Observable
} from "rxjs";
export class ExampleServiceInstance<T> {
private dataObservable: Observable<T>;
constructor(data: () => Observable<T>) {
this.dataObservable = data();
}
get data(): Observable<T> {
return this.dataObservable;
}
reset(): Observable<T> {
return this.dataObservable;
}
}
app/test.ts
import {
Observable,
} from "rxjs";
import {ExampleServiceInstance} from "module1/test.example";
declare type ExampleData = Object[];
class ExampleService {
private service: ExampleServiceInstance<ExampleData>;
constructor() {
this.service = new ExampleServiceInstance<ExampleData>(()=>Observable.of(<ExampleData> []));
}
get data(): Observable<ExampleData> {
return this.service.data;
}
load(): Observable<ExampleData> {
return this.service.reset();
}
}
Expected behavior:
NO TS errors
Actual behavior:
test.ts
(13,58): error TS2345: Argument of type '() => Observable<Object[]>' is not assignable to parameter of type '() => Observable<Object[]>'.
Type 'Observable<Object[]>' is not assignable to type 'Observable<Object[]>'.
Property 'source' is protected but type 'Observable' is not a class derived from 'Observable'.
(17,10): error TS2322: Type 'Observable<Object[]>' is not assignable to type 'Observable<Object[]>'.
Property 'source' is protected but type 'Observable' is not a class derived from 'Observable'.
(21,10): error TS2322: Type 'Observable<Object[]>' is not assignable to type 'Observable<Object[]>'.