Skip to content

Commit

Permalink
chore: add error message for wrongly described events (#8141)
Browse files Browse the repository at this point in the history
Co-authored-by: Nayden Naydenov <[email protected]>
  • Loading branch information
nnaydenow and Nayden Naydenov authored Jan 18, 2024
1 parent 93a7dd3 commit 5e2b89b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/main/src/MultiComboBoxGroupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { IMultiComboBoxItem } from "./MultiComboBox.js";
* that can be used to split the <code>ui5-multi-combobox</code> suggestions into groups.
*
* @constructor
* @extends {UI5Element}
* @extends UI5Element
* @abstract
* @public
* @implements {IMultiComboBoxItem}
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TableGroupRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import tableGroupRowStyles from "./generated/themes/TableGroupRow.css.js";
* @constructor
* @since 1.0.0-rc.15
* @implements {ITableRow}
* @extends {UI5Element}
* @extends UI5Element
* @public
* @slot {Node[]} default - Defines the text of the component. <br> <b>Note:</b> Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
* @csspart group-row - Used to style the native <code>tr</code> element
Expand Down
16 changes: 13 additions & 3 deletions packages/tools/lib/cem/event.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
findAllTags,
getReference,
normalizeDescription,
normalizeTagType
normalizeTagType,
getJSDocErrors
} from "./utils.mjs";

const jsDocRegExp = /\/\*\*(.|\n)+?\s+\*\//;
Expand Down Expand Up @@ -55,8 +56,9 @@ const getParams = (ts, eventDetails, commentParams, classNode, moduleDoc) => {
};

function processEvent(ts, event, classNode, moduleDoc) {
const name = event?.expression?.arguments?.[0]?.text;
const result = {
name: event?.expression?.arguments?.[0]?.text,
name,
_ui5privacy: "private",
type: { text: "CustomEvent" }
};
Expand All @@ -69,7 +71,7 @@ function processEvent(ts, event, classNode, moduleDoc) {

const eventParsedComment = parse(comment, { spacing: 'preserve' })[0];

validateJSDocComment("event", eventParsedComment, event?.expression?.arguments?.[0]?.text, moduleDoc);
validateJSDocComment("event", eventParsedComment, name, moduleDoc);

const deprecatedTag = findTag(eventParsedComment, "deprecated");
const privacy = findTag(eventParsedComment, ["public", "private", "protected"])?.tag || "private";
Expand All @@ -80,6 +82,14 @@ function processEvent(ts, event, classNode, moduleDoc) {
const native = hasTag(eventParsedComment, "native");
const eventDetails = event?.expression?.arguments?.[1]?.properties?.find(prop => prop?.name?.text === "detail")?.initializer?.properties;

if (event?.expression?.arguments?.[1] && !event?.expression?.typeArguments) {
const JSDocErrors = getJSDocErrors();

JSDocErrors.push(
`=== ERROR: Problem found with ${name}'s description in ${moduleDoc.path}: \n\t- Event details have to be described with type via generics type passed to the decorator ( @event<TypeForDetails>("example-name", {details}) ) `
);
}

result.description = description;
result._ui5allowPreventDefault = allowPreventDefault;

Expand Down

0 comments on commit 5e2b89b

Please sign in to comment.