Fix invalid decorator examples in lib.decorators.d.ts - #64353
Open
Fatih Çakır (wfatih) wants to merge 1 commit into
Open
Fatih Çakır (wfatih) wants to merge 1 commit into
Fatih Çakır (wfatih) wants to merge 1 commit into
Conversation
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.
The `@example` blocks on `ClassDecoratorContext.addInitializer` and `ClassMethodDecoratorContext.addInitializer` referenced two types that do not exist: `ClassDecoratorFunction` and `ClassMethodDecoratorFunction`. The second example was also syntactically invalid (a function expression without `=>`), so neither snippet could be copied into an editor. Rewrite both snippets so they type check under `--strict` using the decorator context types that actually ship in this file. Fixes microsoft#54338 Fixes microsoft#54099
Fatih Çakır (wfatih)
force-pushed
the
fix-decorator-jsdoc-examples
branch
from
September 19, 2026 17:52
8ac4f06 to
eb8ec88
Compare
Author
|
@microsoft-github-policy-service agree |
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.
Fixes #54338
Fixes #54099
Problem
Both
@exampleblocks inlib.decorators.d.tsreference types that do not exist in any lib file:ClassDecoratorContext.addInitializerannotates the returned decorator asClassDecoratorFunctionClassMethodDecoratorContext.addInitializerannotatesboundasClassMethodDecoratorFunctionNeither name is declared anywhere in the repository (
git grepfinds only these two comments), so both snippets fail withCannot find name '...'. The second snippet is additionally not parseable —const bound: ClassMethodDecoratorFunction = (value, context) { ... }is missing the=>— so it cannot be pasted into an editor as-is.Change
Both snippets are rewritten in terms of the context types this file actually declares:
Class extends CustomElementConstructor, with the element class extendingHTMLElementsocustomElements.define(name, this)is valid;boundexample is now a generic function declaration takingvalue: Valueandcontext: ClassMethodDecoratorContext<This, Value>, with the dynamic member access done through an explicitRecord<PropertyKey, any>view ofthis.Behaviour of the examples is unchanged; only the annotations and the syntax error are fixed.
Verification
tsc --strict --target es2022 --lib es2022,dom --noEmit.ClassDecoratorFunction/ClassMethodDecoratorFunctionoccur nowhere else in the repo, andtsc/internal/bundled/libs/**is excluded from dprint, so no baselines or formatting output change.AI assistance disclosure
Per CONTRIBUTING.md: this patch was authored with AI assistance (Claude Code). I chose this specific issue, read and verified the resulting change myself, and I will be the one responding to review feedback.