I want to be able to suppress the compile time error that I get from Typescript where I use dot notation to access a property that the compiler doesn't know about. Access with bracket notation works, but dot notation gives a compile error.
My specific case is that I have added a custom matcher (call it 'toLookLike') to Jasmine using Angular. I can use it with brackets notation:
expect(something)['toLookLike'](otherthing);
but using dot notation would be much more readable
expect(something).toLookLike(otherthing);
But the matcher is added at runtime and the compiler doesn't know about it, so I get a compile error if I use the dot notation.
Is there a way to tell Typescript that dot notation is OK in this case? I'd be happy with doing it once, or on every line where the method is used. I do not of course have the ability to add toLookLike to the definition of the jasmine Matcher object.
I'm very familiar with the issues around allowing general dot notation for undefined properties, and in this specific case I'm prepared to take the risk. I don't need an explanation of why dot notation is prohibited in the general case. I've also read and understood this question.