Interfaces
Although we have correctly defined the two functions that are available to users of the ErrorHelper closure, we are missing the second piece of information about the functions available on the ErrorHelper closure—the structure of the response argument. We are not strongly typing the arguments for either of the containsErrors or trace functions. At this stage, our TypeScript code can pass anything into these two functions because it does not have a definition for the response or message arguments. We know, however, that both these functions query our parameters for a specific structure. If we pass in an object that does not conform to this structure, then our JavaScript code will cause runtime errors.
To solve this problem and to ...
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.
Read now
Unlock full access