MCPcopy Index your code
hub / github.com/processing/p5.js / generateParamDeclaration

Function generateParamDeclaration

utils/typescript.mjs:556–580  ·  view source on GitHub ↗
(param, options = {}, allParams = [])

Source from the content-addressed store, hash-verified

554}
555
556function generateParamDeclaration(param, options = {}, allParams = []) {
557 if (!param) return '';
558
559 const name = normalizeIdentifier(param.name);
560
561 // Check if this is an object parameter that we can generate a better interface for
562 const objectInterface = generateObjectInterface(param, allParams, options);
563
564 // Convert the type - should always be an object
565 let type = 'any';
566 if (objectInterface) {
567 type = objectInterface;
568 } else if (param.type) {
569 type = convertTypeToTypeScript(param.type, options);
570 }
571
572 const isOptional = param.optional;
573
574 let prefix = '';
575 if (param.rest) {
576 prefix = '...';
577 }
578
579 return `${prefix}${name}${isOptional ? '?' : ''}: ${type}`;
580}
581
582function generateMethodDeclaration(method, options = {}) {
583 let output = '';

Callers 2

generateClassDeclarationFunction · 0.85

Calls 3

normalizeIdentifierFunction · 0.85
generateObjectInterfaceFunction · 0.85
convertTypeToTypeScriptFunction · 0.85

Tested by

no test coverage detected