Skip to Main Content
Mastering TypeScript 3 - Third Edition
book

Mastering TypeScript 3 - Third Edition

by Nathan Rozentals
February 2019
Beginner content levelBeginner
694 pages
18h 4m
English
Packt Publishing
Content preview from Mastering TypeScript 3 - Third Edition

Class functions

All functions within a class adhere to the syntax and rules that we covered in the previous chapter on functions. As a refresher of these rules, all class functions can:

  • Be strongly typed
  • Use the any keyword to relax strong typing
  • Have Optional parameters
  • Have Default parameters
  • Use argument arrays, or the rest parameter syntax
  • Allow function callbacks and specify the function callback signature
  • Allow function overloads

As an example of each of these rules, let's examine a class that has a number of different function signatures, and we will then discuss each one in detail, as follows:

class ComplexType implements IComplexType { id: number; name: string; constructor(idArg: number, nameArg: string); constructor(idArg: string, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The TypeScript Workshop

The TypeScript Workshop

Ben Grynhaus, Jordan Hudgens, Rayon Hunte, Matt Morgan, Wekoslav Stefanovski

Publisher Resources

ISBN: 9781789536706Supplemental Content