79834952

Date: 2025-12-01 14:32:34
Score: 0.5
Natty:
Report link

As already mentioned by @VLAZ, That is actually not a runtime error. that is a transpile time error. you declared:

type TParser = (str: string, errStr: string) => number;

which is actually wrong. since there is a default parameter, we need to make errStr optional.

type TParser = (str: string, errStr?: string) => number;

notice the added ? before : string,that is used to indicate the parameter is optional, you can give a value to it, or you may not, typescript will allow you.

here are some helpful links:

Optional Parameters Handbook

Optional Parameters in Callback Types Handbook

Function Types Handbook

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @VLAZ
  • Low reputation (0.5):
Posted by: Ssword