Below there is pretty simple example in TypeScript. Could you please explain why 2nd expression in "tests" section is valid (others are not, as it is expected) accordingly to TS playground?
let p = '{pattern}';
let a = 'bar ' + p + ' foo';
let h: { key: string } = { key: a};
let k = 'key';
let n = 0;
// tests
a.replace(p, n);
h[k].replace(p, n);
h.key.replace(p, n);
h['key'].replace(p, n);
My best guess is that it somehow related to hash/or work related with it, but I lack some knowledge..