DEV Community

loading...

Discussion on: Easy functional programming techniques in TypeScript for everyone

Collapse
stereobooster profile image
stereobooster • Edited

Unfortunately, there are not many ways to strictly limit data mutation in TypeScript

type Foo = {
  bar: number;
  bas: number;
}
type FooReadonly = Readonly<Foo>; 

or

const list = ["Apple", "Orange", "Banana", "Grape"] as const;

Mutation doesn't affect referential transparency - reference stays the same.

const test = {}
test.a = 1
test === test
Collapse
deepu105 profile image
Deepu K Sasidharan Author

Yes, I missed that

Collapse
deepu105 profile image
Deepu K Sasidharan Author

I have updated the post