Skip to content

Instantly share code, notes, and snippets.

@carlrip
Created December 17, 2019 18:17
Show Gist options
  • Save carlrip/8a040cc7d2559c7d5209b2546fff64cb to your computer and use it in GitHub Desktop.
Save carlrip/8a040cc7d2559c7d5209b2546fff64cb to your computer and use it in GitHub Desktop.
Readonly arrays
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