Created
January 19, 2021 14:50
-
-
Save luismisanchez/829bbcae60bc2bb3e73ddfa8976691c6 to your computer and use it in GitHub Desktop.
Typescript Generics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generics are types which can hold/ use several types | |
// We're only touching the very basics here - you can go MUCH more into detail | |
// Consider the Array object | |
let numberArray: Array<number>; // This array will only accept numbers | |
// Try to initialize it with strings | |
// numberArray = ['test']; // => Error | |
numberArray = [1,2,3]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment