interface
interface Point {
x: number;
y: number;
}
function printCoord(pt: Point) {
console.log("The coordinate's x value is " + pt.x);
console.log("The coordinate's y value is " + pt.y);
}
printCoord({ x: 100, y: 100 });interface Teams {
turkey: 'fenerbahce' | 'galatasaray',
spain: 'barcelona' | 'real-madrid'
}
let champions: Teams = {turkey: "fenerbahce", spain: "barcelona"}interface SetPoint {
(x: number, y: number): void;
}
type SetPoint = (x: number, y: number) => void;// primitive
type Name = string;
// object
type PartialPointX = { x: number; };
type PartialPointY = { y: number; };
// union
type PartialPoint = PartialPointX | PartialPointY;
// tuple
type Data = [number, string];-Interface extends interface
interface PartialPointX { x: number; }
interface Point extends PartialPointX { y: number; }type PartialPointX = { x: number; };
type Point = PartialPointX & { y: number; };type PartialPointX = { x: number; };
interface Point extends PartialPointX { y: number; }interface PartialPointX { x: number; }
type Point = PartialPointX & { y: number; };interface Point { x: number; }
interface Point { y: number; }
const point: Point = { x: 1, y: 2 };Last updated