Created
December 17, 2019 18:17
-
-
Save carlrip/8a040cc7d2559c7d5209b2546fff64cb to your computer and use it in GitHub Desktop.
Readonly arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Person = { | |
readonly name: string; | |
readonly scores: readonly number[]; | |
} | |
const bob: Person = { | |
name: "Bob", | |
scores: [50, 45] | |
} | |
bob.scores.push(60); // 💥 - Type error - Property 'push' does not exist on type 'readonly number[]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment