datagrok-tools 4.14.32 → 4.14.33
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/package.json +1 -1
- package/plugins/func-gen-plugin.js +18 -12
package/package.json
CHANGED
|
@@ -347,26 +347,32 @@ class FuncGeneratorPlugin {
|
|
|
347
347
|
|
|
348
348
|
_readReturnType(annotation) {
|
|
349
349
|
let resultType = 'dynamic';
|
|
350
|
+
let nodeAnnotation = annotation;
|
|
350
351
|
let isArray = false;
|
|
352
|
+
if (nodeAnnotation?.type === 'TSUnionType' &&
|
|
353
|
+
nodeAnnotation?.types?.length === 2 &&
|
|
354
|
+
nodeAnnotation?.types?.some((e)=> e?.type === 'TSNullKeyword'))
|
|
355
|
+
nodeAnnotation = nodeAnnotation.types.filter((e)=> e.type !== 'TSNullKeyword')[0];
|
|
356
|
+
|
|
357
|
+
|
|
351
358
|
if (
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
359
|
+
nodeAnnotation &&
|
|
360
|
+
nodeAnnotation.type !== 'TSUnionType' &&
|
|
361
|
+
nodeAnnotation.type !== 'TSIntersectionType'
|
|
355
362
|
) {
|
|
356
|
-
|
|
357
|
-
if (annotation.typeName || annotation.type === 'TSTypeReference') {
|
|
363
|
+
if (nodeAnnotation.typeName || nodeAnnotation.type === 'TSTypeReference') {
|
|
358
364
|
resultType =
|
|
359
|
-
|
|
360
|
-
} else if (
|
|
361
|
-
resultType = this._getTypeNameFromNode(
|
|
362
|
-
else if (
|
|
365
|
+
nodeAnnotation.typeName?.right?.name ?? nodeAnnotation.typeName?.name;
|
|
366
|
+
} else if (nodeAnnotation.type !== 'TSArrayType')
|
|
367
|
+
resultType = this._getTypeNameFromNode(nodeAnnotation);
|
|
368
|
+
else if (nodeAnnotation.elementType.type !== 'TSTypeReference') {
|
|
363
369
|
isArray = true;
|
|
364
|
-
resultType = this._getTypeNameFromNode(
|
|
370
|
+
resultType = this._getTypeNameFromNode(nodeAnnotation?.elementType);
|
|
365
371
|
} else {
|
|
366
372
|
isArray = true;
|
|
367
373
|
resultType =
|
|
368
|
-
|
|
369
|
-
|
|
374
|
+
nodeAnnotation?.elementType?.typeName?.name ||
|
|
375
|
+
nodeAnnotation?.elementType?.typeName?.right?.name;
|
|
370
376
|
}
|
|
371
377
|
}
|
|
372
378
|
resultType = typesToAnnotation[resultType];
|