-
Notifications
You must be signed in to change notification settings - Fork 0
Avoid using Object or {}
Jorge Castro edited this page Nov 10, 2025
·
1 revision
function printRowAsTable(data: Object) {
// Returns the data as a table representation, i.e.
// | Key | Value |
// |------|--------|
// | key1 | value1 |
// | key2 | value2 |
// | key3 | value3 |
// |------|--------|
}printRowAsTable({ name: "Alice", age: 30, isActive: true });
printRowAsTable({ "2010": 123, "2011": 456, "2012": 789 });printRowAsTable(new Date());
printRowAsTable([1, 2, 3, 4, 5]);Invalid combinations like in Example 2 are now caught by the type system:
function printRowAsTable(data: Record<string, unknown>) {}- 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