typescript_advanced
TypeScript 5+ advanced patterns, type utilities ve best practices rehberi.
npxskills add vuralserhat86/antigravity-agentic-skills--skill typescript_advancedLoading…
TypeScript 5+ advanced patterns, type utilities ve best practices rehberi.
npxskills add vuralserhat86/antigravity-agentic-skills--skill typescript_advancedLoading…
TypeScript 5+ advanced patterns rehberi.
// Partial - tüm prop'lar optional
type PartialUser = Partial<User>;
// Required - tüm prop'lar required
type RequiredUser = Required<User>;
// Pick - seçili prop'lar
type UserName = Pick<User, 'id' | 'name'>;
// Omit - prop'ları çıkar
type UserWithoutPassword = Omit<User, 'password'>;
// Record - key-value map
type UserMap = Record<string, User>;
// ReturnType - fonksiyon return tipi
type Result = ReturnType<typeof fetchUser>;
type Result<T> =
| { success: true; data: T }
| { success: false; error: string };
function handle(result: Result<User>) {
if (result.success) {
console.log(result.data); // User
} else {
console.log(result.error); // string
}
}
type EventName = `on${Capitalize<string>}`;
// "onClick", "onHover", etc.
type Route = `/${string}`;
type NonNullable<T> = T extends null | undefined ? never : T;
type Flatten<T> = T extends Array<infer U> ? U : T;
import { z } from 'zod';
const UserSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
age: z.number().min(0).max(120),
});
type User = z.infer<typeof UserSchema>;
any - use unknown insteadKaynak: TypeScript 5.0 Release Notes & Total TypeScript Best Practices
interface, union ve karmaşık tipler için type alias'larını belirle.z.infer ile TS tiplerini türet.tsconfig.json dosyasında strict: true ayarının aktif olduğunu doğrula.unknown tiplerini type guards (is, in) veya asserts kullanarak daralt.T extends U ? X : Y yapılarını kullan.extends ile kısıtlayarak tip güvenliğini artır.any: Tüm any kullanımlarını unknown veya spesifik union tipleriyle değiştir.@param, @returns ve @typePara etiketleriyle gelişmiş tipleri dökümante et.| Aşama | Doğrulama |
|---|---|
| 1 | eslint-plugin-typescript hataları temizlendi mi? |
| 2 | "Discriminated Unions" ile tüm case'ler handle edildi mi? |
| 3 | Tip tanımları ile gerçek runtime verileri tutarlı mı? |
TypeScript Advanced v1.5 - With Workflow
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).