Repository navigation
fix: return an empty string for unnamed functions - #111
Open
Zhuyuyangyy wants to merge 1 commit into
Open
Zhuyuyangyy wants to merge 1 commit into
Zhuyuyangyy wants to merge 1 commit into
Conversation
Keep the string return contract when name inference finds no match. Strengthen the existing no-name test and cover anonymous functions, arrow functions, and classes without changing name precedence.
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.
Problem
functionNamedocuments and generates astringreturn type, and already returns""for falsy inputs and stringification errors. However, when neitherdisplayName,name, nor the string-parsing fallback finds a name, it returnsundefined.For example, on the current
main:Change
Fall back to
""when string parsing finds no name, without changing the existingdisplayName→name→ string-parsing precedence. Strengthen the existing unrecognizable-name test to assert the return value, and cover real anonymous functions, arrow functions, and classes.Validation
Local Node.js v24.19.0:
undefinedinstead of"").npm run test-check-coverage: 61 passing, 100% statements, branches, functions, and lines.npm run lint: exit 0; the same 14 pre-existing JSDoc warnings as the unmodified base, no errors.npm run prettier:check: passed.npm run build: passed; declaration remainsFunction → string.--disable-proto=throw, using Node's built-in assertions.Extra-check limitation: running the entire suite with the real Node
--disable-proto=throwflag fails while loading the lockfile's nested@sinonjs/commons@1.8.3through@sinonjs/referee-sinon, before this module or its tests load. Importing that test dependency alone reproduces the failure. The workflow's literalnpm test --disable-proto=throwcompletes, but npm 11 warns that it treats the flag as unknown configuration, so that is not counted as real flag validation. Dependency/CI changes are intentionally out of scope.This focused change and its tests were prepared and checked with AI assistance; no independent human review is being claimed.