Skip to content

Commit 66789e8

Browse files
authored
fix(kernel): Transitively consider properties when deserializing structs (#409)
1 parent 4cb91b3 commit 66789e8

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

packages/jsii-kernel/lib/serialization.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export const SERIALIZERS: {[k: string]: Serializer} = {
289289
}
290290

291291
const namedType = host.lookupType((type as spec.NamedTypeReference).fqn);
292-
const props = propertiesOf(namedType);
292+
const props = propertiesOf(namedType, host.lookupType);
293293

294294
return mapValues(value, (v, key) => {
295295
if (!props[key]) { return undefined; } // Don't map if unknown property
@@ -540,13 +540,24 @@ function mapValues(value: unknown, fn: (value: any, field: string) => any) {
540540
return out;
541541
}
542542

543-
function propertiesOf(t: spec.Type): {[name: string]: spec.Property} {
543+
function propertiesOf(t: spec.Type, lookup: TypeLookup): {[name: string]: spec.Property} {
544544
if (!spec.isClassOrInterfaceType(t)) { return {}; }
545545

546-
const ret: {[name: string]: spec.Property} = {};
546+
let ret: { [name: string]: spec.Property } = {};
547+
548+
if (t.interfaces) {
549+
for (const iface of t.interfaces) {
550+
ret = { ...ret, ...propertiesOf(lookup(iface.fqn), lookup) };
551+
}
552+
}
553+
if (spec.isClassType(t) && t.base) {
554+
ret = { ...ret, ...propertiesOf(lookup(t.base.fqn), lookup) };
555+
}
556+
547557
for (const prop of t.properties || []) {
548558
ret[prop.name] = prop;
549559
}
560+
550561
return ret;
551562
}
552563

packages/jsii-runtime/webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ module.exports = {
2323
use: ['source-map-loader'],
2424
enforce: 'pre'
2525
}]
26+
},
27+
optimization: {
28+
minimize: false
2629
}
2730
}

0 commit comments

Comments
 (0)