SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
202 stars 28 forks source link

Issue with SelectionController taking sId as mSettings #421

Closed junwei-tj closed 1 year ago

junwei-tj commented 1 year ago

Describe the bug The constructor for SelectionController is defined as such:

new SelectionController(sId?: string, mSettings?: {
    control: Control;
    getKeyForItem?: Function;
    targetAggregation: string;
}): SelectionController

Thus, one can expect to instantiate a SelectionController like the following:

new SelectionController('selectionController', {
  targetAggregation: 'columns',
  control: this.table,
}),

However, this causes the following error: SelectionController.js:55 Uncaught Error: Always provide atleast a 'control' configuration when creating a new p13n controller!

Using the debugger on Chrome DevTools, we see that mSettings took on the value of sId: image

The error is gone if sId isn't defined, but it raises a linting error as TypeScript expects sId to be defined before mSettings.

My full code showing how I am using SelectionController:

this.p13nEngine.register(this.table, {
  helper: metadataHelper,
  controller: {
    Columns: new SelectionController({
      targetAggregation: 'columns',
      control: this.table,
    }),
  },
});
akudev commented 1 year ago

Hi, this is actually an issue in the original code/JSDoc, not in the generator for the type definitions. I reported it there: https://github.com/SAP/openui5/issues/3879

Thanks for reporting!

Regards Andreas