Fix swapped charCodeAt/codePointAt JSDoc descriptions - #64224
Open
Shoaib Khan (techreign) wants to merge 1 commit into
Open
Fix swapped charCodeAt/codePointAt JSDoc descriptions#64224Shoaib Khan (techreign) wants to merge 1 commit into
Shoaib Khan (techreign) wants to merge 1 commit into
Conversation
charCodeAt's doc said "Unicode value", which is ambiguous and actually describes codePointAt's behavior. codePointAt's doc led with "UTF-16 encoded code point", obscuring that it returns the full Unicode code point value (handling surrogate pairs), which is what actually distinguishes it from charCodeAt. charCodeAt now says it returns the UTF-16 code unit at the index; codePointAt now says it returns the Unicode code point value, per MDN and the issue discussion. Fixes microsoft#49561 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Shoaib Khan (@techreign) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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.
What was wrong
String.prototype.charCodeAt's JSDoc said it returns the "Unicode value" ofthe character, which is ambiguous and actually describes what
codePointAtdoes. MeanwhilecodePointAt's JSDoc led with "the codepoint value of the UTF-16 encoded code point", which buries the fact that
it returns the full decoded Unicode code point (surrogate pairs handled),
the very thing that distinguishes it from
charCodeAt. Per MDN:charCodeAt()returns the UTF-16 code unit at the given index.codePointAt()returns the Unicode code point value at the givenposition (decoding a surrogate pair if one starts there).
The repo's
src/lib/*.d.tspaths from the original issue have since movedunder the Go-port restructuring; the current source of truth for these
declarations is
tsc/internal/bundled/libs/lib.es5.d.ts(charCodeAt) andtsc/internal/bundled/libs/lib.es2015.core.d.ts(codePointAt). Thehereby libtask only copies these files intobuilt/local, it does notgenerate them, so they're the correct place to fix.
What changed
charCodeAt: doc now says it returns the UTF-16 code unit at the index.codePointAt: doc now leads with "Unicode code point value" instead of"UTF-16 encoded code point", and keeps the existing surrogate-pair detail
(undefined semantics preserved, no behavior/signature change).
Doc comments only, no code or signature changes.
Fixes #49561
How it was verified
npm cicompleted cleanly.npx hereby libran successfully and copied the updated declarationfiles into
built/local, confirming the fix propagates through therepo's lib-copy task without errors.
git diffthat only the two doc comment blocks changed(no generated output is committed;
built/is gitignored).tsc/internal/bundled/libs/**is excluded fromdprint fmt/dprint checkby.dprint.jsonc, andhereby lintruns golangci-lint over theGo modules only, so neither tool applies to these
.d.tsfiles; I didnot run the full Go build/test suite per the task scope (docs-only
change, no compiler behavior affected).
Disclosure
This PR was authored with Claude Code, operated by me (the account owner
who forked and opened this PR). I read and reviewed the diff before
opening this PR, chose this specific issue deliberately, and will handle
CLA acceptance and any review feedback myself.