When I swithch to my Linux PC I get error like this:
app/app.module.ts(21,67): error TS2304: Cannot find name 'Observable'. app/app.module.ts(25,53): error TS2304: Cannot find name 'Observable'. app/app.module.ts(29,68): error TS2304: Cannot find name 'Observable'. app/app.module.ts(33,67): error TS2304: Cannot find name 'Observable'. app/app.module.ts(37,56): error TS2304: Cannot find name 'Observable'. app/app.module.ts(52,27): error TS2304: Cannot find name 'Observable'. app/app.module.ts(52,50): error TS2304: Cannot find name 'Observable'. app/app.module.ts(54,40): error TS2304: Cannot find name '_'. app/app.module.ts(56,24): error TS2304: Cannot find name 'Observable'. app/app.module.ts(58,24): error TS2304: Cannot find name 'Observable'.
Anyone know solution for this?
Also my editor show errors on HttpIntreceptor Class, when I remove it it works fine...
This part is marked: Observable<Response>
Could you check it:
class HttpInterceptor extends Http {
constructor(backend: ConnectionBackend, defaultOptions: RequestOptions, private _router: Router) {
super(backend, defaultOptions);
}
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
return this.intercept(super.request(url, options));
}
get(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.intercept(super.get(url,options));
}
post(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
return super.post(url, body);
}
put(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
return this.intercept(super.put(url, body, this.getRequestOptionArgs(options)));
}
delete(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.intercept(super.delete(url, options));
}
getRequestOptionArgs(options?: RequestOptionsArgs) : RequestOptionsArgs {
if (options == null) {
options = new RequestOptions();
}
if (options.headers == null) {
options.headers = new Headers();
}
options.headers.append('Content-Type', 'application/json');
return options;
}
intercept(observable: Observable<Response>): Observable<Response> {
return observable.catch((err, source) => {
if (err.status == 401 && !_.endsWith(err.url, 'api/auth/login')) {
return Observable.empty();
} else {
return Observable.throw(err);
}
});
}
}
I had the same issue fixed it by importing Observable
import {Observable} from 'rxjs/Rx';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With