შინაარსზე გადასვლა

ტერმინები

რა არის TypeScript?

ვრცლად

TypeScript Anders Hejlsberg-მა (C# creator) 2012-ში გაუშვა Microsoft-ში. ფილოსოფია: gradual adoption — JavaScript file გადაიყვანო .ts-ად, type annotation-ი თანდათან დაამატო, compiler-ი errors-ს ნახავს deploy-მდე.

Ready type system: (1) **Primitives** — string, number, boolean, undefined, null. (2) **Composite** — array, tuple, object, function. (3) **Union** — A | B (multiple options). (4) **Intersection** — A & B (combined). (5) **Generics** — <T> reusable types. (6) **Utility types** — Partial<T>, Required<T>, Pick<T, K>, Omit, ReturnType, Parameters. (7) **Mapped types** — { [K in keyof T]: ... }. (8) **Conditional types** — T extends U ? X : Y. (9) **Template literal types** — `${string}-${number}`.

Real-world wins: (1) **Compile-time errors** save 30-50% debug time. (2) **IDE autocomplete** — IntelliSense across imports. (3) **Refactoring confidence** — rename works correctly across codebase. (4) **API contract enforcement** — Zod schema → TypeScript type generation. (5) **Self-documenting** — types replace half of JSDoc.

Learning curve: (1) Beginners — 1-2 weeks adoption. (2) Mid-level — 2-4 weeks comfortable. (3) Advanced — 6-12 months mastery (conditional types, infer, recursive types).

Craftwebstudio strategy: TypeScript strict mode default 2024-2026. New project skeleton: tsconfig "strict": true. Migration JavaScript → TypeScript: 1-4 weeks medium codebase. Tools: tsc, ESLint @typescript-eslint, Prettier, Zod (runtime validation), tRPC (type-safe API), Drizzle (type-safe ORM).

მაგალითები

  • 1Type inference: const x = 5 → typeof x === number, no annotation needed
  • 2Zod runtime validation + TypeScript type: z.infer<typeof schema> → both
  • 3Discriminated union: type Result = { ok: true, data: T } | { ok: false, error: E }
  • 4Generic component: <Card<T>>({ items }: Props<T>) → reusable type-safe
  • 5Strict mode tsconfig: "strict": true, "noUncheckedIndexedAccess": true → catch 90% bugs

მსგავსი ტერმინები

დაკავშირებული სერვისები

ხშირად დასმული კითხვები

TypeScript ნელი ვიდრე JavaScript?

Runtime იგივე — TypeScript compile-time-ში JavaScript-ში გადაიყვანება. Compile time +5-15% build time, მაგრამ debug time -30-50%. Net win.

TypeScript მცირე პროექტზე ღირს ცდა?

Single-file script — არა (overhead). 5+ files OR team-ი — კი (catch typos, refactor confidence, IDE autocomplete). 2026 industry standard — TypeScript-first.

TypeScript runtime check აკეთებს?

არა — only compile-time. Runtime validation: Zod, Yup, io-ts, ArkType. Pattern: Zod schema → z.infer<>-ით TypeScript type-ი → tsc-ი + Zod-ი double protection.

გინდა უფასო კონსულტაცია?

დაგვიკავშირდი — 24 საათის განმავლობაში დაგიბრუნებთ საპასუხო წერილს პროექტის შეფასებით.

ახლა რთავსCraftwebstudio Mix