I am Software Developer, currently interested in static type languages (TypeScript, Elm, ReScript) mostly in the frontend land, but working actively in Python also. I am available for mentoring.
Hi Maciej. You are absolutely right! That's why it is so good coupled with TypeScript which can prevent mutating a freezed object by refusing to transpile the file.
I am Software Developer, currently interested in static type languages (TypeScript, Elm, ReScript) mostly in the frontend land, but working actively in Python also. I am available for mentoring.
Still I see readonly as a tool for the job. Object.freeze is fully run-time thing and it is decoupled from type definition. Declaration of readonly is included into type definition, so it is explicit. I don't think run-time block is needed here.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It will couse runtime exception. So Object.freeze is not useful in terms of TS.
Hi Maciej. You are absolutely right! That's why it is so good coupled with TypeScript which can prevent mutating a freezed object by refusing to transpile the file.
Still I see
readonly
as a tool for the job.Object.freeze
is fully run-time thing and it is decoupled from type definition. Declaration ofreadonly
is included into type definition, so it is explicit. I don't think run-time block is needed here.