Closed dfenerski closed 2 years ago
@dfenerski The @ui5/ts-interface-generator (supporting control development in TypeScript), which you are apparently using here, is open-sourced. You can find the sources at https://github.com/SAP/ui5-typescript/tree/main/packages/ts-interface-generator and the line where the error appears to occur is here.
It's only the @ui5/dts-generator (generating type definitions for the UI5 JS libraries) which is outdated in this repository and where we still need to publish the current sources. I noticed the readme has not yet been adapted to the creation of the former and have adapted it now in https://github.com/SAP/ui5-typescript/commit/4727e99f1a949af66254aa7d473fc89a3c1b4bba - thanks!
The problem itself... I have to investigate (which might take a while due to UI5con happening this week). In general, this line of code looks at a metadata assignment which is supposed to look like
static readonly metadata = { ....
It seems to find something that is not as expected. Maybe something like
static readonly metadata;
If you want to have a look yourself, you can either set a breakpoint at https://github.com/SAP/ui5-typescript/blob/main/packages/ts-interface-generator/src/interfaceGenerationHelper.ts#L151 and check where metadata[0] lacks the "initializer" property or you can look for suspicious metadata definitions in the project sources.
It was indeed broken metadata on my part. Sorry for the inconvenience, thanks for the support and the insights! Looking forward to the UI5Con..
Thanks for checking!
In which way was it broken? It wouldn't hurt to give a more meaningful error message in such a situation to make the generator more robust..
The value provided to the metadata was recognized as it's 'type', due to being static readonly metadata: { ...
instead of static readonly metadata = { ...
. It slipped past the syntax validation as technically it was valid. A copy-paste mistake caused by the migration of multiple controls at the same time.
@dfenerski the fix I just pushed recognizes a "metadata" member with no initialization and points this out in a warning. The class is then just ignored instead of crashing the generator. Thanks for describing the cause of the issue, so I could prevent others from running into the same problem!
During a migration of a JS library to TS format, I've ran the generator a couple of times to generate interfaces for controls as they were being migrated. Suddenly the generator started crashing with the same error:
Adding --log-level "debug" gave me no useful information about the nature of the error, although I can add logs with the flag if it is necessary. Debugging also seemed a bit harsh, as one is limited to the compiled
dist
files, because this generator is not yet open-sourced as per my understanding.Deleting
node_modules
and doing re-install had no effect.Am I missing something?