Category Archives: TypeScript

TypeScript : Functions : Optional Parameters


I need to allow a parameter to be optional in TypeScript. Optional parameters in TypeScript have to be declared.


Use “?” next to the parameter name to allow the parameter to be optional. The optional parameter must come last in the parameter list but before a REST parameter.


MyFunction(myString: string, myNumberOpt?: number) { ... }