OK so I have jst upgraded a fairly complex app from Angular 8 to 9 (and also on to 10 but this error started in 9)
We had a function as per:
logUserActivity(request: UserActivityRequest): Observable<void> {
const url = `${this.baseUrl}/log-activity`;
request.userId = this.authenticationTokenService.userId();
request.organisationId = isAuthenticationActivity(request.activityType) ? null : this.authenticationTokenService.organisationId();
since the upgrade however we now get:
ERROR TypeError: can't define property "userId": Object is not extensible
The class looks like:
export class UserActivityRequest {
userId: string;
activityType: UserActivityType;
organisationId: string;
moduleId: Modules;
dateCreated: Date;
constructor(
activityType: UserActivityType,
moduleId: Modules = null,
dateCreated: Date = null
) {
this.activityType = activityType;
this.moduleId = moduleId;
this.dateCreated = dateCreated;
}
}
If I do the following the error goes away:
request = {
...request,
userId: this.authenticationTokenService.userId(),
organisationId: isAuthenticationActivity(request.activityType) ? null : this.authenticationTokenService.organisationId()
}
BUT I'd like to understand what the problem is as get other instances elsewhere and it looks fine to me so I'm clearly missing something about the new version of angular/typescript/ngrx
Thanks in advance