Is there a way to suppress the compile time error in Typescript when using dot notation to access a property that the compiler doesn't know about? Even though using bracket notation works, dot notation would be much more readable in my specific case.
In this scenario, I have added a custom matcher called 'toLookLike' to Jasmine using Angular. When using brackets notation, everything functions as expected:
expect(something)['toLookLike'](otherthing);
However, if I try to use dot notation for readability purposes like so:
expect(something).toLookLike(otherthing);
The issue arises because the matcher is added at runtime and not known by the compiler, resulting in a compile error.
How can I inform Typescript that dot notation is permissible in this particular instance? Whether it needs to be done once or on every line of method usage, any solution or workaround is welcome. Unfortunately, I do not have the authority to update the jasmine Matcher object definition to include 'toLookLike'.
I understand the concerns regarding allowing general dot notation for undefined properties but am willing to take the risk in this isolated case. I don't require an explanation on why dot notation is normally restricted. Additionally, I have already reviewed and comprehended this related question.