-
Notifications
You must be signed in to change notification settings - Fork 0
Type Aliases and Interfaces
Jorge Castro edited this page Nov 10, 2025
·
1 revision
function printCoord(pt: {
name: string;
x: number;
y: number;
z: number
}) {
console.log(`${pt.name} has coordinates (${pt.x}, ${pt.y}, ${pt.z})`);
}
function calculateDistance(
pt1: {
name: string;
x: number;
y: number;
z: number;
},
pt2: {
name: string;
x: number;
y: number;
z: number;
}
) {
const dx = pt2.x - pt1.x;
const dy = pt2.y - pt1.y;
const dz = pt2.z - pt1.z;
return Math.sqrt(dx ** 2 + dy ** 2 + dz ** 2);
}type Point3D = {
name: string;
x: number;
y: number;
z: number;
};interface Point3D {
name: string;
x: number;
y: number;
z: number;
};function printCoord(pt: Point3D) {
console.log(`${pt.name} has coordinates (${pt.x}, ${pt.y}, ${pt.z})`);
}
function calculateDistance(pt1: Point3D, pt2: Point3D) {
const dx = pt2.x - pt1.x;
const dy = pt2.y - pt1.y;
const dz = pt2.z - pt1.z;
return Math.sqrt(dx ** 2 + dy ** 2 + dz ** 2);
}- Sync-Obsidian-with-GitHub-on-iOS
- Obsidian-community-plugins
- Optimizing-Novel-Word-Count-Plugin-for-Git-Users
- What is TypeScript, and why you should use it
- Quick setup
- Inference and type annotations
- Fundamental Types
- Object Types
- Union Types
- Type Aliases and Interfaces
- Type Assertions
- Literal Types
- null and undefined
- Narrowing
- Creating Types from Types
- Common Built‐in and Utility Types
- tsc CLI ‐ (The Compiler)
- Avoid using Object or {}
- Ignoring TypeScript errors
- TypeScript resources