Skip to content

Instantly share code, notes, and snippets.

@jaycosaur
Last active August 9, 2020 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaycosaur/eec10a30241ecedbf9f01b3dee40a203 to your computer and use it in GitHub Desktop.
Save jaycosaur/eec10a30241ecedbf9f01b3dee40a203 to your computer and use it in GitHub Desktop.
Implicit vs Explicit typing [typescript] - Typescript to Python field guide
interface Person {
name: string;
age: number;
height: number;
friends: Person[];
}
// Jane implicitly implements the person type
const jane = {
name: "Jane",
age: 25,
height: 1.74,
friends: [],
};
// Tim implicitly implements the person type
const tim: Person = {
name: "Tim",
age: 23,
height: 1.71,
friends: [jane],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment