{"id":16421105,"url":"https://github.com/codermungan/learn-typescript","last_synced_at":"2025-02-24T17:28:44.704Z","repository":{"id":211174037,"uuid":"728405710","full_name":"CoderMungan/learn-typescript","owner":"CoderMungan","description":"A repo containing my notes and codes I took while learning Typescript.","archived":false,"fork":false,"pushed_at":"2023-12-13T12:58:30.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T07:30:49.516Z","etag":null,"topics":["typescript","typescript-learning","typescript-learning-begginer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoderMungan.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-06T21:51:01.000Z","updated_at":"2023-12-13T12:58:57.000Z","dependencies_parsed_at":"2023-12-13T13:37:56.354Z","dependency_job_id":null,"html_url":"https://github.com/CoderMungan/learn-typescript","commit_stats":null,"previous_names":["codermungan/learn-it"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderMungan%2Flearn-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderMungan%2Flearn-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderMungan%2Flearn-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderMungan%2Flearn-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoderMungan","download_url":"https://codeload.github.com/CoderMungan/learn-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223936424,"owners_count":17228130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["typescript","typescript-learning","typescript-learning-begginer"],"created_at":"2024-10-11T07:30:16.766Z","updated_at":"2024-11-10T09:34:17.418Z","avatar_url":"https://github.com/CoderMungan.png","language":"TypeScript","readme":"## Başlangıç\n\nTypescript **Compiler** aşamasında hatalarını gösterir. Compiler aşamasında çalışır.\n\n### Kurulum\n\n```bash\nnpm install -G typescript\n```\n\nşeklinde TypeScript bilgisayarınıza kurulur.\n\n### Type Inference Özelliği\n\nTypeScript eğer ki key’e herhangi bir type ataması yapmadıysanız, typescript keyin ilk value type’ını baz alacaktır. Örn;\n\n```tsx\nlet codermungan = {\n\tisim : \"Mehmet Halil\",\n\tsoyisim : \"MUNGAN\",\n\tyas : 30,\n};\n```\n\nBurada `isim` keyi `string` , `soyisim` keyi `string` , `yas` keyi `number` alacaktır.\n\n### Manuel type verme\n\nGene yukarıdaki örnekten gidecek olursak objenin içerisinde bulunan keylerinin typelarını ayarlamamız gerekmektedir. Örn;\n\n```tsx\nlet codermungan: {isim: string, soyisim: string, yas: number} = {\n\tisim : \"Mehmet Halil\",\n\tsoyisim : \"MUNGAN\",\n\tyas : 30,\n};\n```\n\nancak daha okunaklı ve güzel bir syntax ile yazmamız gerekirse `interface` özelliğini yada `type` özelliğini kullanabiliriz. Örn;\n\n```tsx\n// Objelerin type'ını oluştururken kullanımı daha yaygındır.\ninterface Coder {\n\tisim: string,\n\tsoyisim: string,\n\tyas: number,\n};\n\n// Fonksiyon typelarını oluştururken kullanımı daha yaygındır.\ntype Coder = {\n\tisim: string,\n\tsoyisim: string,\n\tyas: number,\n};\n\nlet codermungan : Coder = {\n\tisim : \"Mehmet Halil\",\n\tsoyisim : \"MUNGAN\",\n\tyas : 30,\n};\n```\n\n### !!! Dikkat\n\n- Objelerde type’lama yaptığınız `key` eğer ki objenizde kullanılmayacaksa hata verecektir. Çünkü `inference` özelliği onun direk type’nı variable olarak tanımladı. Ancak bu durumun da önüne geçebiliriz. Örn;\n\n```tsx\ninterface Coder {\n\tisim: string,\n\tsoyisim: string,\n\tyas?: number,\n};\n\nlet codermungan: Coder = {\n\tisim: \"Mehmet Halil\",\n\tsoyisim: \"MUNGAN\",\n}\n```\n\nşeklinde yazdığımızda `yas` keyi versenizde olur vermeseniz de olur. Bu özelliğe `Optional Property` denmektedir. İsteğe bağlı özellik!\n\n## Ufak Çaplı Trickler\n\n1. İki veya daha fazla type alabilme durumu (**Union Types**):\n\n```tsx\ntype Role = boolean | number; // Boolean yada Number olabilir.\n\ninterface User {\n\tname: string;\n\tpassword: string;\n\trole?: Role; // role Optional Property Boolen veya Number alabilir.\n}\n```\n\n2. Variable atama ve eşleştirme (**Literal Types**):\n\n```tsx\ntype Isim = \"Mehmet Halil\" | \"Mehmet Halil MUNGAN\" | \"CoderMungan\"\n\ninterface Coder {\n\tisim: Isim,\n\tsoyisim: string,\n\tyas: number,\n};\n\nlet codermungan : Coder = {\n\tisim : \"Mehmet Halil\",\n\tsoyisim : \"MUNGAN\",\n\tyas : 30,\n};\n```\n\n## Generic Types\n- Will soon!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodermungan%2Flearn-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodermungan%2Flearn-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodermungan%2Flearn-typescript/lists"}