Conversation
added 5 commits
January 1, 2026 15:41
This was
linked to
issues
Jan 1, 2026
Closed
Closed
Closed
lib/google-font.js
Outdated
Comment on lines
+248
to
+251
| // Attach errors to result for caller inspection if needed | ||
| if (errors.length > 0) { | ||
| /** @type {any} */ (resultList).errors = errors; | ||
| } |
There was a problem hiding this comment.
logic: attaching errors as a property on an array changes the return type - callers expecting Promise<FontResult[]> may not handle the .errors property
Suggested change
| // Attach errors to result for caller inspection if needed | |
| if (errors.length > 0) { | |
| /** @type {any} */ (resultList).errors = errors; | |
| } | |
| // Return both results and errors explicitly | |
| return { results: resultList, errors: errors.length > 0 ? errors : undefined }; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/google-font.js
Line: 248:251
Comment:
**logic:** attaching errors as a property on an array changes the return type - callers expecting `Promise<FontResult[]>` may not handle the `.errors` property
```suggestion
// Return both results and errors explicitly
return { results: resultList, errors: errors.length > 0 ? errors : undefined };
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Greptile Summary
Cleaned up
lib/google-font.jswith several refactoring improvements and bug fixes:utilimportvartoconstfor better scopingDEFAULT_FORMATconstant to eliminate magic string 'ttf' repetition_normalizeVariant()to support 'normal' and 'normalitalic' aliases in addition to '400' and '400italic'saveAtAsync()to collect errors in an array attached to the result rather than silently discarding themThe changes improve code maintainability and make error handling more transparent, though the
.errorsproperty added to the array return type isn't reflected in the TypeScript definitions.Confidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant GoogleFont participant _getFileMapAsync participant _normalizeVariant participant systemFont Client->>GoogleFont: saveAtAsync(variants, destFolder, format) GoogleFont->>GoogleFont: format = format || DEFAULT_FORMAT GoogleFont->>_getFileMapAsync: _getFileMapAsync(format) _getFileMapAsync-->>GoogleFont: fileList (variant->URL map) loop For each requested variant GoogleFont->>_normalizeVariant: _normalizeVariant(variant) Note over _normalizeVariant: Handles '400'/'normal' -> 'regular'<br/>'400italic'/'normalitalic' -> 'italic' _normalizeVariant-->>GoogleFont: normalized variant alt Variant URL exists in fileList GoogleFont->>systemFont: saveAt(url, dest, fileName) alt Success systemFont-->>GoogleFont: file path GoogleFont->>GoogleFont: Add to resultList else Error systemFont-->>GoogleFont: throw error GoogleFont->>GoogleFont: Collect error in errors array end end end alt errors.length > 0 GoogleFont->>GoogleFont: Attach errors to resultList.errors end GoogleFont-->>Client: resultList (with errors if any)