{"id":21620266,"url":"https://github.com/codehunt101/understanding-typescript","last_synced_at":"2025-07-31T09:08:58.183Z","repository":{"id":104165646,"uuid":"482418659","full_name":"CodeHunt101/understanding-typescript","owner":"CodeHunt101","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-17T03:41:30.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T18:25:01.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CodeHunt101.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-17T03:40:11.000Z","updated_at":"2022-04-17T03:40:58.000Z","dependencies_parsed_at":"2023-05-06T20:18:04.475Z","dependency_job_id":null,"html_url":"https://github.com/CodeHunt101/understanding-typescript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CodeHunt101/understanding-typescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeHunt101%2Funderstanding-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeHunt101%2Funderstanding-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeHunt101%2Funderstanding-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeHunt101%2Funderstanding-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeHunt101","download_url":"https://codeload.github.com/CodeHunt101/understanding-typescript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeHunt101%2Funderstanding-typescript/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268016818,"owners_count":24181655,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-24T23:11:08.340Z","updated_at":"2025-07-31T09:08:58.057Z","avatar_url":"https://github.com/CodeHunt101.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Notes\n\n## Install\n\n```\nnpm i -g typescript\n```\nTo compile, run `tsc \u003cfile name\u003e`\n\n## Types\n\n### Core Types\n\n- number\n- string\n- boolean (just these two, no \"truthy/falsy\" values)\n- object\n- array\n- tuple\n- enum (enum { NEW, OLD }) (Added by TypeScript: Automatically enumerated global constant identifiers)\n- any\n\n### Union Types\n\n- Represented by pipes \"|\". They're a combination of types.\n\n### Literal Types\n\n- You can assign your own property values.\n\n### Aliases\n\n- You can creating custom types by adding aliases to refactor and simplify code.\n\n### Function Return Types and Void\n\n- You can specifiy a type to return from a function, but it's better to let TypeScript figure it out.\n- type void means a function doesn't return anything. Eg: it just console log or permorm internal tasks.\n- Don't confuse it with undefined type\n\n### Function types\n\n- We can specify the argument types and the return type of a function\n- Here we tell that the next variable will take a function that accepts two number types as parameters and returns a number:\n\n```ts\nlet combineValues: (a: number, b: number) =\u003e number\n```\n\n### Unknown type\n\n- It's similar to type `any` but it will be more restrictive when combining it with other variable types\n\n### Never type\n\n- In some situations it is literally impossible to return a value, in these cases, TypeScript understands it as a void type, but you can specify it will **never** return any values.\n  \n```ts\nfunction generateError(message: string, code: number): never {\n  throw {message: message, errorCode: code}\n}\n```\n\n## The TypeScript Compiler: configuring \u0026 using it\n\n### Watch Mode\n\n- There's no need to run `tsc \u003cfile name\u003e` every time you make a new change.\n- There's an option that let the user see the changes in real time, which is the __Watch Mode__\n- In order to run Watch Mode, run:\n\n```\ntsc app.ts --watch\n```\n\n### Compiling the entire project\n\n- Usually, on bigger projects. You'll have to run more than one TypeScript file.\n- In order to run __Watch Mode for the entire project__, run:\n\n```\ntsc --init\n```\n\n- To compile all files, run:\n\n```\ntsc\n```\n\n### Include and exclude files\n\n- Check the configuration file `tsconfing.json` and add new keys to include and exclude.\n-To exclude:\n```json\n  // Here we are excluding analytics.ts from compilation\n  \"exclude\": [\n    \"analytics.ts\"\n  ]\n```\n\n- To include:\n```json\n  // Here we are including app.ts for compilation\n  \"include\": [\n    \"app.ts\"\n  ]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodehunt101%2Funderstanding-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodehunt101%2Funderstanding-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodehunt101%2Funderstanding-typescript/lists"}