Created
April 20, 2019 12:09
-
-
Save imkrish/9e55b6954fc2290847c72a6513d171d9 to your computer and use it in GitHub Desktop.
This file contains 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
interface User { | |
readonly id: number; | |
readonly name: string; | |
readonly wifeName: string; | |
readonly parents: ReadonlyArray<string>; | |
} | |
const user: User = { | |
id: 1, | |
name: "John", | |
wifeName: "Mary", | |
parents: ["George", "Maria"] | |
}; | |
user = {}; // Cannot assign to 'user' because it is a constant. | |
user.id = 2; // Cannot assign to 'id' because it is a read-only property. | |
user.wifeName = 'Hermione'; // Cannot assign to 'wifeName' because it is a read-only property. | |
user.parents = []; // Cannot assign to 'parents' because it is a read-only property. | |
user.parents.push("Thor"); // Property 'push' does not exist on type 'readonly string[]'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment