Skip to content

Use semantic type identity for JSDoc augments checks - #4889

Open
Wesley Wigham (weswigham) with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-jsdoc-augments-error
Open

Use semantic type identity for JSDoc augments checks#4889
Wesley Wigham (weswigham) with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-jsdoc-augments-error

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@augments/@extends validation compared raw identifier text, so declaration emit like this incorrectly reported TS8023 even when the extends target was an alias of the augmented base:

declare class Base {}
declare const StateDependencies_base: typeof Base;

/** @augments {Base} */
export declare class StateDependencies extends StateDependencies_base {}
  • Checker behavior

    • Moved the mismatch diagnostic out of class heritage grammar checking and into semantic class checking.
    • Compares the JSDoc augments type against the resolved base class type with isTypeIdenticalTo.
  • Diagnostics and baselines

    • Updated affected baselines for semantic JSDoc type checking.
    • Preserved mismatch diagnostics where the augmented and extended base types are not identical.
  • Regression coverage

    • Added a compiler test covering @augments {Base} with extends through a constructor alias.

Copilot AI and others added 3 commits August 12, 2026 20:28
Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>
Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>
Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix JSDoc '@augments' compilation error in declaration file Use semantic type identity for JSDoc augments checks Aug 12, 2026
@weswigham
Wesley Wigham (weswigham) marked this pull request as ready for review August 13, 2026 20:32
Copilot AI balanced review requested due to automatic review settings August 13, 2026 20:32
@weswigham

Copy link
Copy Markdown
Member

Actually Copilot also limit the check to JS files only - we shouldn't be issuing this (lint?) in .d.ts or .ts files at all anyway.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates JSDoc inheritance validation to compare resolved types, fixing false TS8023 diagnostics for constructor aliases.

Changes:

  • Moves validation from grammar checks into semantic class checking.
  • Adds alias-based regression coverage.
  • Updates affected diagnostic and type baselines.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/checker/checker.go Adds semantic augments/extends type comparison.
internal/checker/grammarchecks.go Removes text-based grammar validation.
testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts Adds constructor-alias regression test.
testdata/tests/cases/compiler/jsdocExtendsClauseMismatch.ts Makes mismatched classes structurally distinct.
testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types Records regression-test types.
testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols Records regression-test symbols.
testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.errors.txt Updates mismatch diagnostic fixture.
testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.types Updates mismatch type baseline.
testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.symbols Updates mismatch symbol baseline.
testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt Records semantic JSDoc generic diagnostics.
testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt Updates implicit-any diagnostics.
testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff Records upstream baseline differences.
testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt Adds unresolved JSDoc type diagnostic.
testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt.diff Removes the resolved baseline difference.
testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt Removes structurally identical mismatch output.
testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff Records the resulting upstream difference.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Actually Copilot also limit the check to JS files only - we shouldn't be issuing this (lint?) in .d.ts or .ts files at all anyway.

Implemented in 489ab56: the augments/extends mismatch validation now returns unless the class is in a JavaScript source file, with TypeScript regression coverage.



==== /b.js (1 errors) ====
class A {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot adjust this test's input to match the intent (testing the augments error) by making A and B not structurally identical.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The test input is in the pinned microsoft/TypeScript submodule. I cannot persist that source change here without an upstream TypeScript commit to update the submodule pointer to; a baseline-only update would fail in a fresh checkout. Please provide or land the upstream revision, and I can pin it and refresh the baselines.

Copilot AI and others added 2 commits August 13, 2026 23:45
Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>
This reverts commit 5098c0b.

Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>
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.

@augments JSDoc tag causes compilation error in generated declaration file

3 participants