I have an angular class that is injectable with a readonly property. I do not have control over the initialization of this class as it is meant to be used in a library. Consumers of this library can access these properties but are not allowed to modify them.
@Injectable()
export class MyState {
readonly requestToken: string;
}
The trick used by the library to write to the property is causing issues.
self.state[<any>"requestToken"] = requestToken;
The problem arises when the name of the property changes and the TypeScript compilation does not detect the string assignment.
Is there a way to obtain the name of the property in a typed manner? Something like:
var nameOfRequestTokenProperty = somethingXxx MyState => requestToken;