angular / angular/angularfire

compilation errors every time a new version of firebase is used

オープン
#3,245 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
7.8k
フォーク
2.2k
平均マージ
22時間 28分
マージ済み PR(30日)
6

説明

I'm sorry if this issue doesn't actually have anything to do with Angularfire, and if it looks more like a question than an actual issue.
Feel free to close this issue if you feel it doesn't belong here.

I use yarn and have configured renovate bot on my project. So every time a new version of Firebase is released, it makes a commit which upgrades the version. And almost every time it does that (like in [this PR](https://github.com/jnizet/decouvertes-nature/pull/282), which upgrades from firebase 9.8.4 to firebase 9.9.0), the code, which compiled fine before, dosn't compile anymore, with errors such as the following one:

```
Error: Error: src/app/activity/activity.service.ts:185:5 - error TS2322: Type 'Observable<(string | FieldValue)[]>' is not assignable to type 'Observable'.
Type '(string | FieldValue)[]' is not assignable to type 'string[]'.
Type 'string | FieldValue' is not assignable to type 'string'.
Type 'FieldValue' is not assignable to type 'string'.
185 return collectionData(this.animatorCollection).pipe(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
186 first(),
~~~~~~~~~~~~~~
...
193 )
~~~~~~~
194 );
```

for code looking like

```ts
export interface Animator {
name: string;
}

// ...
private animatorCollection: CollectionReference;
// ...
suggestAnimators(text: string): Observable> {
const query = text.toLowerCase();
return collectionData(this.animatorCollection).pipe(
first(),
map(animators =>
animators
.filter(a => a.name.toLowerCase().includes(query))
.map(a => a.name)
.sort()
.slice(0, 10)
)
);
}
```

So suddenly, for a reason that I ignore, the compiler doesn't infer the types correctly.

The fix is relatively simple: delete the yarn.lock file, and run yarn again.

But I wonder what I should do to avoid having to do that every time, and would like to understand why this strange behavior happens.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/app/activity/activity.service.ts から始め、yarn.lock を保持したまま Firebase をアップグレードしてコンパイルエラーを再現します。yarn.lock を削除する前後で依存関係の解決結果を比較し、そのうえで、Firebase のアップグレード後も例が一貫してコンパイルされるために必要な、互換性のある依存関係の動作またはプロジェクトの変更を特定します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
database, frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。