feat: declare support for new feature class-covariant-overrides
#4924
+2
−1
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.
This adds support for the new
class-covariant-overrides
feature into@jsii/spec
.class-covariant-overrides
relaxes the existing restriction on covariant overrides 1. With the feature it is now allowed to override thetype of readonly class properties
and thereturn type of class methods
when extending other classes, as long as the changes are covariant 2 3 to the superclass. Importantly, covariant overrides are still not allowed when implementing interfaces.Compilers that are producing assemblies with covariant class overrides MUST include
class-covariant-overrides
in theusedFeatures
set.This feature does not require any changes to the kernels, runtimes or packmak. All generated code already is already correct when given an appropriate assembly. We can now add support for this feature due to the upgrade to
net6.0
4 which was the only thing blocking it.Proof all of this is working together: #4925
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Footnotes
https://aws.github.io/jsii/user-guides/lib-author/typescript-restrictions/#covariant-overrides-parameter-list-changes ↩
https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science) ↩
As of today this feature strictly applies to class and interface types, event though some built-in types like lists might also be technically covariant. ↩
https://github.com/aws/jsii/pull/4916 ↩