Implementing a typed response in a simple GET request seems to be causing a strange behavior in the compiler. The application compiles successfully, but a red error is returned with the message displayed in the VS Code screenshot below:
ERROR in src/app/services/product.service.ts(49,5): error TS2558: Expected 0 type arguments, but got 1.
https://i.sstatic.net/X49qc.png
Here is the relevant code snippet:
src/app.component.ts
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Device } from './model/device';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
devices: Device[];
constructor(private http: HttpClient) {
this.getAll();
}
getAll() {
this.http.get<Device[]>('http://localhost:3000/devices')
.subscribe(result => this.devices = result);
}
}
interface
export interface Device {
id?: number;
label?: string;
os?: string;
price?: number;
memory?: number;
rate?: number;
desc?: string;
}
Any insights on why this error is occurring would be greatly appreciated.
Thank you for the support.