Question mark Typescript variable
In TypeScript, <name>?: <typename>
a shorthand for <name>: <typename> | undefined
.
This indicates to the type system that a symbol may contain a value of the indicated type or it may contain the value undefined
(which is like null
).
This is important when the (new in TypeScript 2) --strictNullChecks
option is enabled. The documentation on Null- and undefined-aware types option is probably where you should start to understand why this is useful.