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.
Hi! It may be worth mentioning that
"TypeScript comes with a ReadonlyArray type that is the same as Array with all mutating methods removed, so you can make sure you don’t change your arrays after creation"
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.
Virtually everywhere you say "TypeScript", you seem to mean "JavaScript". It is not TypeScript that treats functions as first-class objects, or lazily evaluates boolean expressions. It's JavaScript. TypeScript is merely JavaScript with type annotations.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
Hi there, great article! Did you know that you can use
Object.freezeto prevent mutating an array or an object?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
readonlyas a tool for the job.Object.freezeis fully run-time thing and it is decoupled from type definition. Declaration ofreadonlyis included into type definition, so it is explicit. I don't think run-time block is needed here.Yes, I thought of writing about it but then missed
or
Mutation doesn't affect referential transparency - reference stays the same.
I have updated the post
Yes, I missed that
Hi! It may be worth mentioning that
"TypeScript comes with a ReadonlyArray type that is the same as Array with all mutating methods removed, so you can make sure you don’t change your arrays after creation"
typescriptlang.org/docs/handbook/i...
Oh yes, I completely forgot about those
Stack, Map and Queue are not data types related to FP, they have FP implementations, but still the sentence is wrong.
I have rephrased it
Sure they are not related to FP, what I meant was that they are more appropriate for the FP approach
Virtually everywhere you say "TypeScript", you seem to mean "JavaScript". It is not TypeScript that treats functions as first-class objects, or lazily evaluates boolean expressions. It's JavaScript. TypeScript is merely JavaScript with type annotations.
Yes, and thats why I keep saying typeScript/JavaScript and also I made it clear in the beginning that TS is just a superset of JS
What kind of markdown do you use to link to the other articles at the top? It looks neat!
Its the series feature in Dev, if you add
series: my series nameto the front matter of the post-it links them up that way