polyfill: Update type definition to support exactOptionalPropertyTypes#3100
polyfill: Update type definition to support exactOptionalPropertyTypes#3100
exactOptionalPropertyTypes#3100Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3100 +/- ##
=======================================
Coverage 96.05% 96.05%
=======================================
Files 21 21
Lines 9951 9951
Branches 1802 1802
=======================================
Hits 9558 9558
Misses 346 346
Partials 47 47 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ptomato
left a comment
There was a problem hiding this comment.
Makes sense to me, though maybe @justingrant would like to take a look?
|
This seems fine. I'd suggest we wait under all API-affecting normative changes are merged (or are we already there?) and then see if anything needs to be revised as a result of type changes from those normative changes. |
|
Apologies ahead of time for the interjection, but this seems a bit odd to me and peaked my curiosity. I think I understand the premise, but the type definitions on the options already appear correct to me, and this adds an extra variant that is not totally true for the types. For instance, Is this just a side effect of types on a TypeScript library API? Or does EDIT: for relevant background, I'm obviously a bit more familiar with Rust library APIs than TypeScript library APIs. And so this could just be a type system difference, but thought I'd confirm |
If a property or parameter is optional, then If a parameter or property is market optional but it's not optional, then you're correct and we should change types to make it non-optional. |
|
I think this is OK to merge as we don't expect any further API-affecting normative changes. |
The
exactOptionalPropertyTypesoption in TypeScript bans passingundefinedto optional properties unlessundefinedis allowed explicitly, because optional properties andundefinedproperties behave differently in JavaScript, to be precise.https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes
For example, above code result in the error below with
exactOptionalPropertyTypes.As I understand it, Temporal's API doesn't distinguish optional properties and properties with
undefinedin passed objects (XXLikeobjects and options) and passingundefinedas a value is safe.This pull request allows passing
undefinedto Temporal's built-in methods under theexactOptionalPropertyTypesoption in TypeScript.note: usage of
Partialin the type definition is no longer necessary because original type contains only optional properties, so I removed it for clean-up. I'll revert it if there is a reason to leavePartialas is.