Here is an example of an interface I have defined:
export interface Parameter {
access: string;
value: string;
}
export interface Parameters {
parameter: Map<string, Parameter>;
}
In my code, I am trying to use the above interface like this:
@Pipe({ name: 'opStatus' })
export class OpStatusPipe {
transform(parameters: Parameters): any {
if (parameters.parameter["X1"].value == "true" &&
parameters.parameter["X2"].value == "true") {
return "Operational"
} else {
return "Not Operational"
}
}
}
The issue I am encountering is that when I use functions of the Map (such as set, get, entries, has) Angular allows me to run 'ng serve', but in the browser I keep getting an error saying
parameter property does not have function
.
If I change those functions to JavaScript style (e.g. parameter["x"].access = "text"
, parameters["x"] + "sometext"
) then sometimes 'ng serve' fails with the error message Element implicitly has an 'any' type because type 'Map<string, Parameter>' has no index signature. Did you mean to call 'Parameter.get'
, but the browser always works.
I have looked everywhere for a solution but haven't found one yet. Any help would be greatly appreciated.
Angular CLI: 11.0.1
Node: 14.15.0
OS: win32 x64