typescript-signals icon indicating copy to clipboard operation
typescript-signals copied to clipboard

Parameter cannot have a question mark and initializer

Open leegrey opened this issue 11 years ago • 1 comments

Hi. Not sure if you are still maintaining this...

This may be a change in the TypeScript specification since the time you last pushed, but in its current form it gives the error:

"Parameter cannot have a question mark and initializer "

In several situations like this:

public has(listener, context?: any = null): bool

It's happy if you remove the question mark though. :)

leegrey avatar Apr 25 '14 11:04 leegrey

http://stackoverflow.com/questions/17186566/how-do-i-fix-error-ts1015-parameter-cannot-have-question-mark-and-initializer

「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.」

RhinoLu avatar Jun 14 '15 03:06 RhinoLu