angular / angular/angularfire

compilation errors every time a new version of firebase is used

Abierto
#3,245 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
7.8k
Forks
2.2k
Merge medio
22 h 28 min
PR fusionados (30 d)
6

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con src/app/activity/activity.service.ts y reproduce el error de compilación actualizando Firebase mientras conservas yarn.lock. Compara la resolución de dependencias antes y después de eliminar yarn.lock y determina a continuación el comportamiento compatible de las dependencias o el cambio necesario en el proyecto para que el ejemplo compile de forma consistente después de las actualizaciones de Firebase.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
database, frontend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.