# You should be using TypeScript and here is why?
## Index
1. Generalities
2. Everyday types
3. Common patterns
4. Advance typing
5. Limits of expressivity
6. Resources
- Powerful inference leverages **intentionality**
- [Type compatibility](https://www.typescriptlang.org/docs/handbook/type-compatibility.html) is structural subtyping
- Embraces JavaScript common patterns
- Assumes **you** know more
- Has no effect on runtime
- Common types
- `unknown` vs `any`
- Optional keys, `null` and `undefined`
- Type aliases
[Try it out](https://www.typescriptlang.org/play?#code/PTAEFEDVwJQTQCIEE6gCpwArgMoCgRQBeE0ssvAsAYQHsBbe2gO1ABcBPABwFMBnKqAC0I0WJGVCAIjQALAJZ9Qi0AENQfNgCd5zAOYAadgqUr1zAK70ARjy0A6R1LwAbHm1AKAYloYA5OAAuDW1dPWJQAHJZWhd1ADNfelAAgEJI13c1LR0ANzC4HlUtYMsbOwiAJgAGGsyPAHdVPiQAcVpaABNC4uDrDrdVViJ2LQseetBOvLCAGXkAYx5mPh4kNjYeei42PmCEVU2AbQBdCKO8UFBmHgbQA82ACkiAKQtWSoBGIxqvyIBKAyXa63e6HHjPJAWcKfADMP1qnwBQKuNzuDwhkQA8gsPAA2BF-f54E6TGL0Hh0WhaTq6cF7UAAb1ALhYenkbAsnR4pSsti0RjibA5XJ51z5FQAvhFGcDWfoRdzgkIAOyw+wqvG1FEsw6KsUAFk+9mqsLxAFY8JLJGApEhQPF3rj5CxjIc1AsljslOpNDp9PZnI7mM7XXotDx3I9w5HhfoGX6wv8mcCFiw+LEePZWXpoxH3GE+MTrYI7Q6ncLXWxZO6I5ytCs1OLyg4gxWXawhnwGnY0LR5vEeABVZjyXJ2VZIZidcDjrQcathR7-XktlNXOsWBugA2VK020AyWQ8DQ8NPT0BcYqqCmbLTKJS0HYd1QuQN4YOh1hbLg1vjyAAvHhOlafM2DzWNC2CRN9CMH8-0UWYeHHFwAH5giGDhk1lK54OaRDkJ4FwIjw-8+CQlDQFQ1DQGqVN00zbNaFzGMC3jUAAGoonSewI14Q5HlIgiUP+YsDykK9OiQ+JwOT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0qRsB+wTQD9OqUY8xa9giROuDYxxxR5KsAANLFE6K6cmzBfqqRSVMDp6SOzeJcDktAk81AuHkM0fgSMq7iQtk0bq7BaCgD4hGEBGNQCVAQJeP63V3wXyWN1OwwQjiNKMI0s4Iwjif1oqSUsABZRShjaAACszxOx9JnNQ-Qu6fN2qnUANyhgeHoIpCGrApoOm0u1eg74yVJN2u884wK6Gkgvu7acDBaV3SOl8tg9LwUwsOLIXiOcGDLiMPy6sQq2X0GXKSIAA) in the TypeScript playground!
- [OOP goodies](https://www.typescriptlang.org/docs/handbook/2/classes.html)
- [Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)
- [Utility types](https://www.typescriptlang.org/docs/handbook/utility-types.html)
[Try it out](https://www.typescriptlang.org/play?#code/PTAEGEHkFlsg5UAFAggFTQUQErwMoBQIoAvGeRZQUWJJEqAOYD2zAJgJYCmAzjaAFohwkQOrEARHmYBbLgBcAFhwB2jUAGMAhitAcZABwA2XOSvmglXUBIAyOtjK0AnANYS95rs4BmWjVwAdBIEqvLefgGg9iqOLq6gAN4EoKBGzGoc8gCubFwAXKAq2TIARt4paVryWbkFRSXlzgQAvtQaRlo8PBBZAJ56hiZm8j0xcW5JlRoZPPLO2RryzM4AFJWpBtmlRhwaRVpyhXPOqowANBugWzt7aRmMtXmFxWXel6mb27v7nTU5zwab2aqQAlFNUm02iYLPIXIwFOBWM5OCpqrxSEUuAB3XryPqrADkAHVlOFkJ1VDxCedBAB2ADMgTpADYAEwATlpABYAIyBAAMDO5AtB4jAEhQumYpQAVlwlnoelpNLIDMweFlrMwfDZwOkeFw2HhFFoDFwPA49cx0s4jSazRbgqEvL5-NZ9Rr7abzRDQC4uFpVqCXo13pUTGolMHQ8DWtQwhF3RAbStvY6-TNbcd5md4wQYaAdtkuABVFRZABCzAAHoVPYbjT7rAAyFO29O+kh+gNB8GJUB2nLOXS80AtD5pLhRxTBpKDhTZEegbnjydZlaFQnFriE-OSFCaTrdUA+FaqjtsIu1jH6Yymac1NS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E8Bj6F0VHsFCe6827yD7gPbw+NXFGOkT4mex8LEEjYQZMhRIIk9TToRHgNogjpEYESIJZwijMGxKo+J9lKj2IMKJNB34YmEkKXkmqRFkmBFSUSPAywDCZJUNk3J2ioTtFqtcVy7kgl3TFAYQIL9zGGOenORRSQWgDKGSobyvA5pjPBBMxIUywalhqLsfElg+jmiBmAEGBywYBTtKdDIRgBglW4LiHUL5rCQwtJ3P8oA-YAEkiIN1ImzP0iEWmAgDnjNmx9Eln1Iq-PGkscYAuJlE6BPy8auTxoJY+zVbYlhjKAbAgZpoqHOYTZmUKOaEjDoSTmYS07iWXNfX5QQw5IsqCi02OdZkhgxVis5fQ8VSwJezbaztpwkrJZ8ClklYXUsCIyqOSKhKFipB8883Y3K4lee8su5kfZ+zFIWCVDNMSytVc4cVfKVCHSNbg0Ws49Z2xXNnKOltxygiAA) in the TypeScript playground!
- [Template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html)
- [Mapped types](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html)
- [Type predicates](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
[Try it out](https://www.typescriptlang.org/play?#code/PTAEEEBEDVwOQMIFFQBUCaAFAknA4gFAigC8Z5FFBRYAMgJYAuApgE4CGANqPQHYusADgHtO7RvWG8aoALTyFipcuqMAnoOag8zRgLjsAtswA84PawPHQzAB4teAEwDOoZ41Z8A5gD5SoAAMvXQASAG8EdkEmLnoAL1NzDytmHwBfAIIAYyl3UF4jZh09NgAubV19QpMAcgLjGr8SUBrgxnrmGuzcxlB2YOKBcsG2FNr+zqaWtvBgrpkAWSjNR1B1TWcZZRUZACJwN11QYQAzUE1WQ1cT1mFDPsPe09AsqPYAI3pOJnpmZwA6XYEdZaSKCD5fH5-fwAJWYOVYjhM7k8vC8ABpQO9hKJmOxeD5gRotJg2FcTAgbPZmE5XGCId8JH8pnCEUiANbMNTPBCY7G4-GEgicI6OZgAN3oWWY9M+jN+rmaYQIoGOml4mA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zo-j4wk8H3GPOPdygAJ4K4X+1sy7vT-CCZ4oDyAtA1l0T+J0W7Vxvs-XeT9t67y7mnZ2hte4l1YFAs+51ME0l6qAf4hgohTxtn4a+-9nYsTfpVf4+NNSo3IuKTEzhi7lRIH4fh9x4a8NAEDb0QA) in the TypeScript playground!
## Limits of expressivity
Some relations [I cannot get them work](https://www.typescriptlang.org/play?#code/PTAEEEBEDVwOQMIFFQBUCaAFAknA4gFAigC8Z5FFBRYAMgJYAuApgE4CGANqPQHYusADgHtO7RvWG8aoALTyFipcuqMAnoOag8zRgLjsAtswA84PawPHQzAB4teAEwDOoZ41Z8A5gD5SoAAMvXQASAG8EdkEmLnoAL1NzDytmHwBfAIIAYyl3UF4jZh09NgAubV19QpMAcgLjGr8SUBrgxnrmGuzcxlB2YOKBcsG2FNr+zqaWtvBgrplUDS1DKOjeL2cZZW3qYgAicDddUGEAM1BNVkNXU9ZhQz6j3rPQLKj2ACN6TiZ6ZmcAHR7AjqTSgSKCT7fX7-fwAJWYOVYjhM7k86wANKAPsJRMx2LwfCClqBMGxriYEDZ7MwnK4IVCfhJ-lMEUiUQBrZhqF4ILE4vEEokETjHRzMABu9CyzAZXyZf1czTCBFAJ00vEwAFdOM5mOUPFrmBjVaAAI7CD4AKwNrCNJrVZvYzkMAGZyqcuHqCGlqDleHktXrWGSrkrQCq1cINdrdfrQJ64w7zZabQmvcbTU6Xe7QIbmD7dmADk8TudaRJGKLjPwbncHowABZaHKGL4FCRSMuvd7ymGuAmOC7kwHA0FaJD8JjVitjADS1IcLjcHm8UwCb14AFU9eEITEfgkTHP0plx6BJ5WZ7XKYvacu5dDmc4ppHQABtOfcni8UBcnnnFSzoXlOVbMDWjBjGi3igAAZKAX5qD4AC65QCqKBKFqKvRBmwl7TuBFbhm0+FgRBzgABTilKMqPgq-xYrhIYjgAlAQTGkdejCAtGtKxt6HGgVxgKbjuzAAPIxjq3oEKcWq8Fkna-iRQmETeVJ2Eu9K9k+io+BRppvJCfbPuUfKmpc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8hXifF+JMbE9J6ysl9QBCsQQ3TGF+CcWEzxjSikAhWo4LUaMKISixM4bxFUSB+F+Q8BG3zQDAx9EAA) in the TypeScript playground!
- TypeScript [handbook](https://www.typescriptlang.org/docs/handbook/).
- TypeScript [playground](https://www.typescriptlang.org/play).