Skip to content

Instantly share code, notes, and snippets.

@mattbajorek
Last active April 10, 2020 14:37
Show Gist options
  • Save mattbajorek/65782de8f848fe0834b54f8e3eeda894 to your computer and use it in GitHub Desktop.
Save mattbajorek/65782de8f848fe0834b54f8e3eeda894 to your computer and use it in GitHub Desktop.
TypeScript no generics example
Object.values(groupedNumberData).forEach(numberArray => {
numberArray.forEach(num => {
// This won't work without a type assert or type check
console.log((num as number) * 2);
});
});
Object.values(groupedStringData).forEach(stringArray => {
stringArray.forEach(str => {
// This won't work without a type assert or type check
console.log((str as string).length);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment