This module introduces you to Interfaces in TypeScript.
The objectives of this module are to provide you with an understanding of:
- How to use Function Types
- How to use Optionals
- How to use Excess Property Checks
- How to use Indexable Types
- How Interfaces work with Classes
- How to create Extendable Interfaces
This learning path is aimed at all who wish to learn how to use TypeScript
We welcome all feedback and suggestions - please contact us at firstname.lastname@example.org to let us know what you think.
Similar to interfaces that describe function types, we can describe types we can index into. These indexable types have an index signature that describes the types we can use to index the object. Along with the corresponding types returned when indexing. The GarageArray1 interface specifies that each number index must have a string value. We define an array to implement a GarageArray1 interface. We can then access the string by using the array name and the index number. The GarageArray2 interface specifies that each index is a string and the value is a number. We define an array to implement the GarageArray2 to interface we can then access the number using the key. You can make index signatures read only to stop them being mutated. The third GarageArray demonstrates this with the interphase specifying read only and the error message when trying to reassign a key value.
Ed is an Outstanding Trainer in Software Development, with a passion for technology and its uses and holding more than 10 years’ experience.
Ed is responsible for delivering QA’s Programming Foundations course using the Eclipse IDE. His skillset extends into the DevOps sphere, where he is able to deliver courses based around Agile/Scrum practices, version control, and CI/CD.