Skip to content

correct nodejs Render return typedef from boolean|object to false|{...}#88

Merged
dominikwilkowski merged 3 commits intodominikwilkowski:releasedfrom
erictheswift:render-typefix
Sep 5, 2025
Merged

correct nodejs Render return typedef from boolean|object to false|{...}#88
dominikwilkowski merged 3 commits intodominikwilkowski:releasedfrom
erictheswift:render-typefix

Conversation

@erictheswift
Copy link
Contributor

Currently Render returns boolean or untyped object.
This seems to be a jsdoc mistype.

See built Render.d.ts diff:

--- Render.d.ts
+++ Render.d.ts
@@ -1,7 +1,24 @@
 /**
  * Main method to get the ANSI output for a string
  */
-export type ReturnObject = (object | boolean);
+export type ReturnObject = {
+    /**
+     * - The pure string for output with all line breaks
+     */
+    string: string;
+    /**
+     * - Each line of output in an array
+     */
+    array: Array<string>;
+    /**
+     * - The number of lines
+     */
+    lines: number;
+    /**
+     * - All options used
+     */
+    options: object;
+};
 /**
  * Main method to get the ANSI output for a string
  *
@@ -13,15 +30,15 @@
  * @param  {number}  size.width  - The width of the terminal
  * @param  {number}  size.height - The height of the terminal
  *
- * @typedef  {(object|boolean)} ReturnObject
- *   @property {string}  string  - The pure string for output with all line breaks
- *   @property {array}   array   - Each line of output in an array
- *   @property {number}  lines   - The number of lines
- *   @property {object}  options - All options used
+ * @typedef  {object} ReturnObject
+ *   @property {string}        string  - The pure string for output with all line breaks
+ *   @property {Array<string>} array   - Each line of output in an array
+ *   @property {number}        lines   - The number of lines
+ *   @property {object}        options - All options used
  *
- * @return {ReturnObject}        - CLI output of INPUT to be consoled out
+ * @return {ReturnObject|false}        - CLI output of INPUT to be consoled out
  */
 export function Render(input: string, SETTINGS?: object, debug?: boolean, debuglevel?: number, size?: {
     width: number;
     height: number;
-}): ReturnObject;
+}): ReturnObject | false;

Copy link
Owner

@dominikwilkowski dominikwilkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Can you move the type fix in the DisplayHelp.js fine into the jsdocs so the js still works?

@erictheswift
Copy link
Contributor Author

Thanks for the contribution. Can you move the type fix in the DisplayHelp.js fine into the jsdocs so the js still works?

Fixed prettier issue.

As I understand, https://github.com/dominikwilkowski/cfonts/blob/released/nodejs/src/DisplayHelp.js is a pure render api consumer without any typedefs needed (checked by test:types script).

Could you elaborate which further changes are expected?

Copy link
Owner

@dominikwilkowski dominikwilkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dominikwilkowski
Copy link
Owner

Ok we're ready. Thanks for the contribution. Will release a new nodejs version this weekend

@dominikwilkowski dominikwilkowski merged commit a20d960 into dominikwilkowski:released Sep 5, 2025
25 checks passed
@dominikwilkowski
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants