I have defined an interface which goes something like following
export interface Parameter {
access: string;
value: string;
}
export interface Parameters {
parameter: Map<string, Parameter>;
}
I am trying to use the above interface as follows
@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"
}
}
}
Now the problem I am facing is that if I use any functions of the Map (set, get, entries, has) then Angular is happy and I can at least run 'ng serve' but then in the browser I keep getting error parameter property does not have function.
And if I change those functions to JavaScript style (e.g. parameter["x"].access = "text" , parameters["x"] + "sometext" then Angular serve fails sometimes (Element implicitly has an 'any' type because type 'Map<string, Parameter>' has no index signature. Did you mean to call 'Parameter.get') but browser works always.
I tried to searched everywhere but didn't get any solution. Help is much appreciated.
Angular CLI: 11.0.1
Node: 14.15.0
OS: win32 x64
targetin tsconfig.json? Also, what browser are you testing in?"target": "es2015",i am usingChrome Version 86.0.4240.198parameters.parameter["X1"] == "true"doesn't make sense whenparameters.parameter["X1"]is according to your interface an object with the propertiesaccessandvalue.parametersactually is aMapobject? Your interface only defines what it should be, not what it is at runtime.