@ui5/webcomponents-tools 2.5.0-rc.2 → 2.5.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.5.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.2...v2.5.0-rc.3) (2024-12-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * **framework:** add strict event type checking ([#10235](https://github.com/SAP/ui5-webcomponents/issues/10235)) ([4ff8ab7](https://github.com/SAP/ui5-webcomponents/commit/4ff8ab7c34db5058b92511767be1b96c69a91cb5))
12
+
13
+
14
+
15
+
16
+
6
17
  # [2.5.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.1...v2.5.0-rc.2) (2024-11-28)
7
18
 
8
19
  **Note:** Version bump only for package @ui5/webcomponents-tools
package/lib/cem/event.mjs CHANGED
@@ -20,16 +20,6 @@ const ASTFalseKeywordCode = 94;
20
20
 
21
21
  const getParams = (ts, eventDetails, commentParams, classNode, moduleDoc) => {
22
22
  return commentParams?.map(commentParam => {
23
- const decoratorParam = eventDetails?.find(prop => prop?.name?.text === commentParam?.name);
24
-
25
- if (!decoratorParam || !decoratorParam?.jsDoc?.[0]) {
26
- return;
27
- }
28
-
29
- const decoratorParamParsedComment = parse(decoratorParam?.jsDoc?.[0]?.getText?.(), { spacing: 'preserve' })[0];
30
-
31
- validateJSDocComment("eventParam", decoratorParamParsedComment, decoratorParam.name?.text, moduleDoc);
32
-
33
23
  const { typeName, name } = getType(normalizeTagType(commentParam?.type));
34
24
  let type;
35
25
 
@@ -48,12 +38,10 @@ const getParams = (ts, eventDetails, commentParams, classNode, moduleDoc) => {
48
38
  return {
49
39
  type,
50
40
  name: commentParam?.name,
51
- _ui5privacy: getPrivacyStatus(decoratorParamParsedComment),
41
+ _ui5privacy: "public",
52
42
  description: normalizeDescription(commentParam?.description),
53
- _ui5since: getSinceStatus(decoratorParamParsedComment),
54
- deprecated: getDeprecatedStatus(decoratorParamParsedComment),
55
43
  };
56
- }).filter(pair => !!pair);
44
+ });
57
45
  };
58
46
 
59
47
  function processEvent(ts, event, classNode, moduleDoc) {
@@ -80,7 +68,7 @@ function processEvent(ts, event, classNode, moduleDoc) {
80
68
  const commentParams = findAllTags(eventParsedComment, "param");
81
69
  const description = normalizeDescription(eventParsedComment?.description);
82
70
  const native = hasTag(eventParsedComment, "native");
83
- const eventArgs = event?.expression?.arguments;
71
+ const eventArgs = event?.expression?.arguments;
84
72
  let eventBubbles;
85
73
  let eventCancelable;
86
74
  let eventDetails;
@@ -97,10 +85,6 @@ function processEvent(ts, event, classNode, moduleDoc) {
97
85
  });
98
86
  });
99
87
 
100
- if (eventDetails && !event?.expression?.typeArguments) {
101
- logDocumentationError(moduleDoc.path, `Event details for event '${name}' must be described using generics. Add type via generics to the decorator: @event<TypeForDetails>("${name}", {details}).`)
102
- }
103
-
104
88
  result.description = description;
105
89
  result._ui5Cancelable = eventCancelable !== undefined ? eventCancelable : false;
106
90
  result._ui5allowPreventDefault = result._ui5Cancelable;
@@ -108,16 +92,6 @@ function processEvent(ts, event, classNode, moduleDoc) {
108
92
 
109
93
  if (native) {
110
94
  result.type = { text: "Event" };
111
- } else if (event?.expression?.typeArguments) {
112
- const typesText = event?.expression?.typeArguments.map(type => type.typeName?.text).filter(Boolean).join(" | ");
113
- const typeRefs = (getTypeRefs(ts, event.expression)
114
- ?.map(e => getReference(ts, e, event, moduleDoc.path)).filter(Boolean)) || [];
115
-
116
- result.type = { text: `CustomEvent<${typesText}>` };
117
-
118
- if (typeRefs.length) {
119
- result.type.references = typeRefs;
120
- }
121
95
  }
122
96
 
123
97
  if (privacy) {
@@ -138,7 +112,53 @@ function processEvent(ts, event, classNode, moduleDoc) {
138
112
  : sinceTag.name;
139
113
  }
140
114
 
141
- if (commentParams && eventDetails) {
115
+ const eventDetailType = classNode.members?.find(member => member.name.text === "eventDetails")?.type;
116
+ const eventDetailRef = eventDetailType?.members?.find(member => member.name.text === name) || eventDetailType?.types?.[eventDetailType?.types?.length - 1]?.members?.find(member => member.name.text === name);
117
+ const hasGeneric = !!event?.expression?.typeArguments
118
+ // if (name ==="value-state-change") {
119
+ // debugger
120
+ // }
121
+ if (commentParams.length) {
122
+ if (eventDetailRef && hasGeneric) {
123
+ logDocumentationError(moduleDoc.path, `Event details for event '${name}' has to be defined either with generic or with eventDetails.`)
124
+ } else if (eventDetails) {
125
+ if (hasGeneric) {
126
+ const typesText = event?.expression?.typeArguments.map(type => type.typeName?.text).filter(Boolean).join(" | ");
127
+ const typeRefs = (getTypeRefs(ts, event.expression)
128
+ ?.map(e => getReference(ts, e, event, moduleDoc.path)).filter(Boolean)) || [];
129
+
130
+ result.type = { text: `CustomEvent<${typesText}>` };
131
+
132
+ if (typeRefs.length) {
133
+ result.type.references = typeRefs;
134
+ }
135
+ } else if (eventDetailRef) {
136
+ const typesText = eventDetailRef?.type?.typeName?.text;
137
+ const typeRefs = (getTypeRefs(ts, eventDetailRef)
138
+ ?.map(e => getReference(ts, e, event, moduleDoc.path)).filter(Boolean)) || [];
139
+
140
+ result.type = { text: `CustomEvent<${typesText}>` };
141
+
142
+ if (typeRefs.length) {
143
+ result.type.references = typeRefs;
144
+ }
145
+ } else {
146
+ logDocumentationError(moduleDoc.path, `Event details for event '${name}' must be described using generics. Add type via generics to the decorator: @event<TypeForDetails>("${name}", {details}).`)
147
+ }
148
+ } else if (eventDetailRef) {
149
+ const typesText = eventDetailRef?.type?.typeName?.text;
150
+ const typeRefs = (getTypeRefs(ts, eventDetailRef)
151
+ ?.map(e => getReference(ts, e, event, moduleDoc.path)).filter(Boolean)) || [];
152
+
153
+ result.type = { text: `CustomEvent<${typesText}>` };
154
+
155
+ if (typeRefs.length) {
156
+ result.type.references = typeRefs;
157
+ }
158
+ } else {
159
+ logDocumentationError(moduleDoc.path, `Event details for event '${name}' must be described.`)
160
+ }
161
+
142
162
  result._ui5parameters = getParams(ts, eventDetails, commentParams, classNode, moduleDoc);
143
163
  }
144
164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "2.5.0-rc.2",
3
+ "version": "2.5.0-rc.3",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -86,5 +86,5 @@
86
86
  "esbuild": "^0.19.9",
87
87
  "yargs": "^17.5.1"
88
88
  },
89
- "gitHead": "9208967c396111dd2ee4bf45f3a5fea021fa5704"
89
+ "gitHead": "bb0393d3daabde7c97e6b5028ae81e34a5b060dc"
90
90
  }