You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ts-interface-generator): no error when parent class has no c'tor (#474)
This in particular addresses the common case when Component.js inherits
from the sap/fe/core/AppComponent, which has no constructor.
This used to cause the error 'Component inherits from ManagedObject and
has metadata but the parent class
"sap/fe/core/AppComponent".AppComponent seems to have no settings type.
It might have no constructors, this is where the settings type is used.
Or the settings type used there and its inheritance chain could not be
resolved.'
Actually, AppComponent does have a settings type, but it is not found
without constructor and it is never used and unneeded, because it
inherits from the UIComponent settings type without adding anything,
like this:
export interface $AppComponentSettings extends $UIComponentSettings {}
Copy file name to clipboardExpand all lines: packages/ts-interface-generator/src/interfaceGenerationHelper.ts
+56-21Lines changed: 56 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -269,6 +269,8 @@ Or is there a different reason why this type would not be known?`,
269
269
return;
270
270
}
271
271
272
+
// invariant: there is exactly one metadata block with an initializer
273
+
272
274
// now check whether there is a settings type in the superclass
273
275
// (which the generated settings type needs to inherit from)
274
276
// There really should be, because all descendants of ManagedObject should have one!
@@ -308,11 +310,11 @@ Or is there a different reason why this type would not be known?`,
308
310
}
309
311
}elseif(metadata){
310
312
thrownewError(
311
-
`${
313
+
`'${
312
314
statement.name ? statement.name.text : ""
313
-
} inherits from ${interestingBaseClass} and has metadata but the parent class ${typeChecker.getFullyQualifiedName(
315
+
}' inherits from '${interestingBaseClass}' and has metadata, but the parent class '${typeChecker.getFullyQualifiedName(
314
316
type.getSymbol(),
315
-
)} seems to have no settings type. It might have no constructors, this is where the settings type is used. Or the settings type used there and its inheritance chain could not be resolved.
317
+
)}' seems to have no settings type. It might have no constructors - this is where the settings type is used. Or the settings type used there and its inheritance chain could not be resolved.
316
318
317
319
In case this parent class is also in your project, make sure to add its constructors, then try again. A comment with instructions might be in the console output above.
318
320
Otherwise, you can temporarily remove this file (${
@@ -432,7 +434,10 @@ function isOneAStringAndTheOtherASettingsObject(
432
434
* Returns the type of the settings object used in the constructor of the given type
433
435
* Needed to derive the new settings object type for the subclass from it.
// TODO: but it could be that the metadata is not an object literal, but a variable or a function call, which returns the metadata object.
734
+
// This is not supported yet, but could be in the future. Warn the user about this.
735
+
log.warn(
736
+
`Class '${className}' inside '${fileName}' inherits from ${interestingBaseClass} and has a 'metadata' property, but no object literal is assigned to this property. This is not supported (yet?), hence no TypeScript interface is generated for this class by @ui5/ts-interface-generator.`,
0 commit comments