Closed lionel-rowe closed 7 months ago
Hi @lionel-rowe,
Thanks for reporting this. This appears to be a widespread issue here and with the Office JS APIs that sit underneath the Office Scripts API. @gergzk and I will start investigating a fix for both the type definitions and the documentation, though it will likely take some time.
While we acknowledge this issue, there is no timeline for a complete fix. We will be updating individual APIs to indicate null
and undefined
behavior as we are able. I'm closing this issue to reflect this level of investment.
Article URL
https://github.com/OfficeDev/office-scripts-docs-reference/blob/main/generate-docs/script-inputs/excel.d.ts
Issue
Office Scripts TypeScript types provide no null safety — mostly not clear where nulls are/aren't allowed or occur:
DataValidation#getValid
is typed() => boolean
, whereas it's really() => boolean | null
.Table#setPredefinedTableStyle(null)
to remove all table styles is completely undocumented (parameter is typed asstring
).The inline Code Editor in Excel also provides no null safety. For example:
Here,
nullable
is typed as1
, andnullable.toString()
will throw a runtime error 50% of the time.Presumably this is a tsconfig issue, so maybe outside the scope of documentation, but seems the issues are related.