Tengo un problema con el archivo de typescript
en angular mas precisamente con un subscribe, alguien sabe como darme una mano?
El error que me tira es el siguiente
No overload matches this call.
Overload 1 of 3, '(observer?: Partial<Observer<Object>> | undefined): Subscription', gave the following error.
Type '(producto: ProductoDescripcion) => void' has no properties in common with type 'Partial<Observer<Object>>'.
Overload 2 of 3, '(next: (value: Object) => void): Subscription', gave the following error.
Argument of type '(producto: ProductoDescripcion) => void' is not assignable to parameter of type '(value: Object) => void'.
Types of parameters 'producto' and 'value' are incompatible.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
Type 'Object' is missing the following properties from type 'ProductoDescripcion': categoria, desc1, desc2, producto, and 3 more.
Overload 3 of 3, '(next?: ((value: Object) => void) | null | undefined, error?: ((error: any) => void) | null | undefined, complete?: (() => void) | null | undefined): Subscription', gave the following error.
Argument of type '(producto: ProductoDescripcion) => void' is not assignable to parameter of type '(value: Object) => void'.
Types of parameters 'producto' and 'value' are incompatible.
Type 'Object' is not assignable to type 'ProductoDescripcion'.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?ts(2769)
Mi código es el siguiente
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ProductosService } from '../../services/productos.service';
import { ProductoDescripcion } from '../../interfaces/producto-descripcion.interface';
@Component({
selector: 'app-item',
templateUrl: './item.component.html',
styleUrls: ['./item.component.css']
})
export class ItemComponent implements OnInit {
producto!: ProductoDescripcion;
id!: string;
constructor( private route: ActivatedRoute,
public productoService: ProductosService ) { }
ngOnInit() {
this.route.params.subscribe( parametros => {
// console.log(parametros['id']);
**Mi error se produce en ese subscribe**
this.productoService.getProducto(parametros['id'])
.subscribe( (producto: ProductoDescripcion) => {
this.id = parametros['id'];
this.producto = producto;
});
});
}
}