datagrok-tools 4.14.0 → 4.14.1
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.
|
@@ -375,10 +375,11 @@ const reservedDecorators = exports.reservedDecorators = {
|
|
|
375
375
|
function generateClassFunc(annotation, className, sep = '\n') {
|
|
376
376
|
return annotation + `export function _${className}() {${sep} return new ${className}();${sep}}${sep.repeat(2)}`;
|
|
377
377
|
}
|
|
378
|
+
const primitives = new Set(['string', 'string[]', 'number', 'number[]', 'boolean', 'boolean[]']);
|
|
378
379
|
|
|
379
380
|
/** Generates a DG function. */
|
|
380
381
|
function generateFunc(annotation, funcName, sep = '\n', className = '', inputs = [], isAsync = false) {
|
|
381
|
-
let funcSigNature = inputs.map(e => `${e.name}: ${e.type}`).join(', ');
|
|
382
|
+
let funcSigNature = inputs.map(e => `${e.name}: ${primitives.has(e.type ?? '') ? e.type : 'any'}`).join(', ');
|
|
382
383
|
let funcArguments = inputs.map(e => e.name).join(', ');
|
|
383
384
|
return annotation + `export ${isAsync ? 'async ' : ''}function ${funcName}(${funcSigNature}) {${sep} return ${className.length > 0 ? `${className}.` : ''}${funcName}(${funcArguments});${sep}}${sep.repeat(2)}`;
|
|
384
385
|
}
|
package/package.json
CHANGED
|
@@ -179,10 +179,11 @@ class FuncGeneratorPlugin {
|
|
|
179
179
|
name += ': ' + generate(baseParam.argument.typeAnnotation.typeAnnotation).code;
|
|
180
180
|
|
|
181
181
|
let type = '';
|
|
182
|
-
if (baseParam?.typeAnnotation?.typeAnnotation
|
|
183
|
-
type = 'any';
|
|
184
|
-
else if (baseParam?.typeAnnotation?.typeAnnotation)
|
|
182
|
+
if (baseParam?.typeAnnotation?.typeAnnotation)
|
|
185
183
|
type = generate(baseParam.typeAnnotation.typeAnnotation).code;
|
|
184
|
+
else
|
|
185
|
+
type = 'any';
|
|
186
|
+
|
|
186
187
|
let params = baseParam.typeAnnotation.typeAnnotation.typeArguments?.params;
|
|
187
188
|
if(type !== 'any' && params && params.length > 0)
|
|
188
189
|
type += `<${params.map((e)=>e.typeName.name).join(',')}>`;
|