If you look in the TypeScript Language Specification document you can find a wealth of detail about the language syntax.
Section 3.9.2 describes call signatures i.e. the syntax used to call functions and constructors etc.
Section 3.9.2.2 is specifically about the parameters associated with a call.
It defines optional parameters as:
AccessibilityModifieropt BindingIdentifierOrPattern ? TypeAnnotationopt
AccessibilityModifieropt BindingIdentifierOrPattern TypeAnnotationopt Initializer
We can see see that either using '?' OR providing a default value Initializer will mark the parameter as being optional.
So to fix the compiler error you can simply remove the '?' and leave the default value and it will remain as an optional parameter as you intend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With