Description
Line 105 in 150921d
On the above line - the user is warned that their original constructor will be overrided, but there is no way to prevent this via configuration.
This becomes dangerous in a larger codebase, when the probability for naming collisions increases. Consider the following example
src/login/form.ts
export class LoginForm {
constructor() {
// renders a simple login form
}
}
declarePersistable(LoginForm);
src/oauth/form.ts
export class LoginForm {
constructor() {
// renders an oauth confirmation screen
}
}
declarePersistable(LoginForm);
// this will overwrite the original LoginForm
Now the simple solution is just to "not do this", but as the number of persistable objects grows - the chances for this type of collision increases as well. Codebases which have additional log statements might mask the severity of this mistake.
My suggestion is that we use some environment variable - perhaps SERIALIJSE_SAFE_MODE
to fail loudly anytime the described situation occurs. I would happily open a pull request if we are in agreement.
Thanks for your time,
Brian
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.