Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TS for Functional Programmers.md #3334

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ immutable. The referent is still mutable:
```js
const a = [1, 2, 3];
a.push(102); // ):
a[0] = 101; // D:
a[0] = 1; // D:
```

TypeScript additionally has a `readonly` modifier for properties.
Expand Down Expand Up @@ -574,7 +574,7 @@ as well as special syntax for this type:
let a: ReadonlyArray<number> = [1, 2, 3];
let b: readonly number[] = [1, 2, 3];
a.push(102); // error
b[0] = 101; // error
b[0] = 1; // error
```

You can also use a const-assertion, which operates on arrays and
Expand All @@ -583,7 +583,7 @@ object literals:
```ts
let a = [1, 2, 3] as const;
a.push(102); // error
a[0] = 101; // error
a[0] = 1; // error
```

However, none of these options are the default, so they are not
Expand Down