Interfaces and Type Declarations
Video Lecture
Description
In TypeScript, Interfaces and Type declarations offer almost the same exact functionality, in this video we explore that idea. An Interface/Type is a structure used for type-checking. An Interface/Type defines the properties and types an object can have.
interface Quux {
quuz: string
corge: number
}
function foo(bar: Quux) {
return 'Hello, ' + bar.quuz + ' ' + bar.corge
}
let baz: Quux = { quuz: 'ABC', corge: 123 }
console.log(foo(baz))
Try it,
tsc foo.ts
node foo.js