The issue is that currently Feathers throws a type error if you try to modify anything that isn't part of the userPatchSchema, even if you are using _patch. You get an error similar to this, Argument of type { isAdmin: boolean; } is not assignable to parameter of type { username: string; }
This is very frustrating to deal with, since the code is perfectly valid.
This PR attempts to address that type issue.
Other Information
I have tried my best in testing this, I ran the test script and all passed. I also tried this against my local feathers app and it seems to work correctly. I spent a decent bit of time on figuring out these whole 12 lines of changes. This was seemingly the simplest way of fixing the types, without breaking a lot of stuff
Summary
With this given schema
You may want a user to be able modify their own username, but obviously not set
isAdmin
totrue
whenever they want.So you have a patch schema that only permits the username to be modified.
But the backend still retains the ability to modify any property by using underscore methods.
_patch
ignores all hooks and can setisAdmin
totrue
The issue is that currently Feathers throws a type error if you try to modify anything that isn't part of the
userPatchSchema
, even if you are using_patch
. You get an error similar to this,Argument of type { isAdmin: boolean; } is not assignable to parameter of type { username: string; }
This is very frustrating to deal with, since the code is perfectly valid.
This PR attempts to address that type issue.
Other Information
I have tried my best in testing this, I ran the test script and all passed. I also tried this against my local feathers app and it seems to work correctly. I spent a decent bit of time on figuring out these whole 12 lines of changes. This was seemingly the simplest way of fixing the types, without breaking a lot of stuff