I really need to be able to check dynamically if aa is a property of my complex object called validations
const check = 'propertya' + 'a'; // result of a complex calculation that returns string 'propertyaa'
validations= {
'a' : {
'propertyaa': 'ax',
'ab': 'ay',
'ac': 'az'
},
'b' : {
'ba': 'ax',
'bb': 'ay',
'bc': 'az'
}
};
if (this.validations.a[check] === undefined) { ...
Error is:
element implicitly has an any type because type '{ ' propertyaa': string, 'ab': string, 'ac': string; }' has no index signature
(property) 'a': {
'propertyaa': string;
'ab': string;
'ac': string;
}
Curiously the static (not dynamic) variant works if (this.validations.a['ab']) {
this.validations.a[check]? I can't reproduce this.