5

I'm getting a typescript compilation error when using angularfire2:

Property 'take' does not exist on type 'FirebaseObjectObservable'

I'm importing the take operator from rxjs so this question doesn't help: AngularFire2 typings: "Property 'take' does not exist on type 'FirebaseObjectObservable<any>'"

Imports:

import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2';
import { Subscription } from 'rxjs';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/throttleTime';
import 'rxjs/add/operator/take';

Code that causes error:

this.af.database.object(`/xyz`).take(1);

Compiles if I cast to 'any':

var test: any = this.af.database.object(`/xyz`);
test.take(1);

Versions:

"typescript": "^2.1.4"  
"rxjs": "^5.0.3"
"angularfire2": "^2.0.0-beta.6-preview"

I also tested and using 'take' on an rxjs Observable works fine. Since FirebaseObjectObservable extends Observable it should also work fine. Any ideas why typescript is giving me an error here?

Community
  • 1
  • 1
Will
  • 2,790
  • 19
  • 22
  • According to `npm info angularfire2 dist-tags`, `2.0.0-beta.6` is the latest version. I'd change the dependency to `"angularfire2": "2.0.0-beta.6"` and would try that. It might not fix the problem, but you'll have the latest version. – cartant Jan 08 '17 at 22:56
  • Importing `take` - as you do in your question - it works fine for me with `2.0.0-beta.6`. – cartant Jan 08 '17 at 23:15
  • Possible duplicate of [Angular 2 beta.17: Property 'map' does not exist on type 'Observable'](http://stackoverflow.com/questions/36947748/angular-2-beta-17-property-map-does-not-exist-on-type-observableresponse) – olsn Jan 09 '17 at 08:36
  • 1
    There are issues in the current beta that relate to non-peer dependencies. You should check inside `node_modules/angularfire2/node_modules` and delete any `firebase` or `rxjs` directories (as they should be peers). Or you could update to `2.0.0-beta.7.1-pre`. – cartant Jan 09 '17 at 22:08
  • I updated to 7.1-pre and did a clean npm install and things are working as expected now. Thank you everyone. – Will Jan 14 '17 at 16:53

1 Answers1

1

Updating to angularfire2 2.0.0-beta.7.1-pre and doing a clean npm install fixed the issue.

Will
  • 2,790
  • 19
  • 22