Skip to content

Commit 1593ae0

Browse files
feat: allow covariant overrides in classes (backport #2324) (#2385)
# Backport This will backport the following commits from `main` to `maintenance/v5.8`: - [feat: allow covariant overrides in classes (#2324)](#2324) <!--- Backport version: 9.5.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Momo Kornher <kornherm@amazon.co.uk>
1 parent 97a10d7 commit 1593ae0

22 files changed

+813
-91
lines changed

src/assembler.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class Assembler implements Emitter {
226226
jsiiVersion,
227227
bin: this.projectInfo.bin,
228228
fingerprint: '<TBD>',
229-
usedFeatures: this.usedFeatures.size > 0 ? Array.from(this.usedFeatures) : undefined,
229+
usedFeatures: _assemblyFeatures(this.usedFeatures), // might be appended later
230230
};
231231

232232
if (this.deprecatedRemover) {
@@ -249,6 +249,15 @@ export class Assembler implements Emitter {
249249

250250
const validator = new Validator(this.projectInfo, assembly);
251251
const validationResult = validator.emit();
252+
253+
// Inject detected features
254+
if (validationResult.usedFeatures) {
255+
for (const item of validationResult.usedFeatures) {
256+
this.usedFeatures.add(item);
257+
}
258+
assembly.usedFeatures = _assemblyFeatures(this.usedFeatures);
259+
}
260+
252261
if (!validationResult.emitSkipped) {
253262
const zipped = writeAssembly(this.projectInfo.projectRoot, _fingerprint(assembly), {
254263
compress: this.compressAssembly ?? false,
@@ -269,6 +278,10 @@ export class Assembler implements Emitter {
269278
this._afterEmit();
270279
}
271280

281+
function _assemblyFeatures(usedFeatures: Set<spec.JsiiFeature>): spec.JsiiFeature[] | undefined {
282+
return usedFeatures.size > 0 ? Array.from(usedFeatures).sort() : undefined;
283+
}
284+
272285
function _loadReadme(this: Assembler) {
273286
// Search for `README.md` in a case-insensitive way
274287
const fileName = fs

src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type MultipleSourceFiles = {
2828
/**
2929
* Assembly features supported by this compiler
3030
*/
31-
export const ASSEMBLY_FEATURES_SUPPORTED: spec.JsiiFeature[] = ['intersection-types'];
31+
export const ASSEMBLY_FEATURES_SUPPORTED: spec.JsiiFeature[] = ['intersection-types', 'class-covariant-overrides'];
3232

3333
/**
3434
* Compile a piece of source and return the JSII assembly for it

0 commit comments

Comments
 (0)