TypeScript Notları
  • Giriş
  • Handbook
    • TypeScript nedir, ne işe yarar ?
    • Kurulum ve tsc
    • Temel Tipler
    • any ve unknown
    • Union Type (Çoklu Tipler)
    • Literal Types
    • Objects (Objeler)
    • Arrays (Diziler)
    • Tuple
    • Fonksiyonlar
    • Optional Params (Opsiyonel Parametreler)
    • type
    • interface
    • readonly
    • Generics
    • Modül Yapısı
    • Type Assertion
    • keyof, typeof
    • Mapped Types
    • React ve TypeScript
      • Props Tipleri
      • State Tipleri
      • Event Tipleri
      • useRef
  • Tip and Tricks
    • json2ts
  • Kaynakça
Powered by GitBook
On this page
  1. Handbook

Modül Yapısı

TypeScript ES Module yapısını destekler. Örneğin tip tanımlamalarını yaptığımız types.ts adında bir dosyamız olsun.

types.ts
type User = {
    name: string;
    id: number;
}

export {User};

Oluşturduğumuz User isimli tip objesini projemizin farklı yerlerinde kullanmak istiyoruz. Kullanmak için tek yapmamız gereken User'ı dosyamıza import etmek.

index.js
import {User} from "./types";

let users:User;
users = {name:'Osman',id:142}

PreviousGenericsNextType Assertion

Last updated 3 years ago