Add types from index to quarterOfYear #2823
Open
+11
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves an issue where a variable being passed in as unit that may conform to either the base function's expected type (e.g., ManipulateType) or the augmented function's type (QUnitType) would be considered a type violation:
The types as they stand currently have two overloads: one that takes the base types and one that takes the extended types; neither take both, when really, the plugin makes it so that the function can take both kinds. This causes an error when I may pass in
'quarters'
or'weeks'
becauseQUnitType
adds'quarters'
toUnitType
andOpUnitType
/ManipulateType
adds'weeks'
but there is no type that has both.This PR could also add this as a separate overload, if that were important. E.g.:
But I don't think it is – I don't see any value in an overload only accepting
QUnitType
.Another open question, I suppose: here are the types today:
Should the
QUnitType
being passed toadd
/subtract
also beManipulate
d, excluding'date' | 'dates'
? Are'date' | 'dates'
valid values foradd
/subtract
only when the plugin is added?Maybe:
And maybe
QUnitType
should extendOpUnitType
rather thanUnitType
? Which would make most of the changes in this PR obsolete, except that we'd replaceadd#unit
/subtract#unit
withManipulateQType
?