From 93fdd9c2711997e0d097ffb5b1842051d382cb78 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:14:44 +0000 Subject: [PATCH 1/7] Initial plan From 43ca46eb9595172ee122b0f142c072112afa2adc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:28:01 +0000 Subject: [PATCH 2/7] Fix JSDoc augments alias comparison Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com> --- internal/checker/checker.go | 23 +++++++++++++++++++ internal/checker/grammarchecks.go | 18 --------------- .../jsdocAugmentsAliasExtends.symbols | 18 +++++++++++++++ .../compiler/jsdocAugmentsAliasExtends.types | 18 +++++++++++++++ .../jsdocExtendsClauseMismatch.errors.txt | 4 ++-- .../jsdocExtendsClauseMismatch.symbols | 12 ++++++---- .../compiler/jsdocExtendsClauseMismatch.types | 6 +++-- .../compiler/jsdocAugmentsAliasExtends.ts | 10 ++++++++ .../compiler/jsdocExtendsClauseMismatch.ts | 4 ++-- 9 files changed, 84 insertions(+), 29 deletions(-) create mode 100644 testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols create mode 100644 testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types create mode 100644 testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 19024b26ffd..043299896e7 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -4324,6 +4324,7 @@ func (c *Checker) checkClassLikeDeclaration(node *ast.Node) { baseTypes := c.getBaseTypes(classType) if len(baseTypes) != 0 { baseType := baseTypes[0] + c.checkJSDocAugmentsTagMatchesExtends(node, baseTypeNode, baseType) baseConstructorType := c.getBaseConstructorTypeOfClass(classType) staticBaseType := c.getApparentType(baseConstructorType) c.checkBaseTypeAccessibility(staticBaseType, baseTypeNode) @@ -4399,6 +4400,28 @@ func (c *Checker) checkClassLikeDeclaration(node *ast.Node) { c.checkPropertyInitialization(node) } +func (c *Checker) checkJSDocAugmentsTagMatchesExtends(node *ast.Node, baseTypeNode *ast.ExpressionWithTypeArgumentsNode, baseType *Type) { + for _, j := range node.EagerJSDoc(nil) { + if j.AsJSDoc().Tags == nil { + continue + } + for _, tag := range j.AsJSDoc().Tags.Nodes { + if tag.Kind != ast.KindJSDocAugmentsTag { + continue + } + sourceTypeNode := tag.ClassName() + if c.isTypeIdenticalTo(c.getTypeFromTypeNode(sourceTypeNode), baseType) { + continue + } + targetName := getIdentifierFromEntityNameExpression(baseTypeNode.Expression()) + sourceName := getIdentifierFromEntityNameExpression(sourceTypeNode.Expression()) + if targetName != nil && sourceName != nil { + c.error(sourceName, diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, tag.TagName().Text(), sourceName.Text(), targetName.Text()) + } + } + } +} + func (c *Checker) checkClassForStaticPropertyNameConflicts(node *ast.Node) { if c.compilerOptions.GetUseDefineForClassFields() { return diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index 8ebf5826a3e..0d9af76e14d 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -912,24 +912,6 @@ func (c *Checker) checkGrammarClassDeclarationHeritageClauses(node *ast.ClassLik return c.grammarErrorOnFirstToken(typeNodes[1], diagnostics.Classes_can_only_extend_a_single_class) } - if len(typeNodes) > 0 { - for _, j := range node.EagerJSDoc(file) { - if j.AsJSDoc().Tags == nil { - continue - } - for _, tag := range j.AsJSDoc().Tags.Nodes { - if tag.Kind == ast.KindJSDocAugmentsTag { - target := typeNodes[0].AsExpressionWithTypeArguments() - source := tag.ClassName().AsExpressionWithTypeArguments() - targetName := getIdentifierFromEntityNameExpression(target.Expression) - sourceName := getIdentifierFromEntityNameExpression(source.Expression) - if targetName != nil && sourceName != nil && targetName.Text() != sourceName.Text() { - return c.grammarErrorOnNode(sourceName, diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, tag.TagName().Text(), sourceName.Text(), targetName.Text()) - } - } - } - } - } seenExtendsClause = true } else { if heritageClause.Token != ast.KindImplementsKeyword { diff --git a/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols new file mode 100644 index 00000000000..d6d31e42cf6 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/jsdocAugmentsAliasExtends.ts] //// + +=== jsdocAugmentsAliasExtends.ts === +declare class Base { +>Base : Symbol(Base, Decl(jsdocAugmentsAliasExtends.ts, 0, 0)) +} +declare const StateDependencies_base: typeof Base; +>StateDependencies_base : Symbol(StateDependencies_base, Decl(jsdocAugmentsAliasExtends.ts, 2, 13)) +>Base : Symbol(Base, Decl(jsdocAugmentsAliasExtends.ts, 0, 0)) + +/** + * @augments {Base} + */ +export declare class StateDependencies extends StateDependencies_base { +>StateDependencies : Symbol(StateDependencies, Decl(jsdocAugmentsAliasExtends.ts, 2, 50)) +>StateDependencies_base : Symbol(StateDependencies_base, Decl(jsdocAugmentsAliasExtends.ts, 2, 13)) +} + diff --git a/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types new file mode 100644 index 00000000000..80cbd00936d --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/jsdocAugmentsAliasExtends.ts] //// + +=== jsdocAugmentsAliasExtends.ts === +declare class Base { +>Base : Base +} +declare const StateDependencies_base: typeof Base; +>StateDependencies_base : typeof Base +>Base : typeof Base + +/** + * @augments {Base} + */ +export declare class StateDependencies extends StateDependencies_base { +>StateDependencies : StateDependencies +>StateDependencies_base : Base +} + diff --git a/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.errors.txt b/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.errors.txt index 40b7607935e..36133207c24 100644 --- a/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.errors.txt +++ b/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.errors.txt @@ -3,8 +3,8 @@ main.js(2,20): error TS8023: JSDoc '@extends Component' does not match the 'exte ==== react.d.ts (0 errors) ==== declare namespace React { - class Component {} - class PureComponent {} + class Component { component: string } + class PureComponent { pure: string } } ==== main.js (1 errors) ==== diff --git a/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.symbols b/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.symbols index 4cb5611ab1f..c05a72a7427 100644 --- a/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.symbols +++ b/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.symbols @@ -4,11 +4,13 @@ declare namespace React { >React : Symbol(React, Decl(react.d.ts, 0, 0)) - class Component {} + class Component { component: string } >Component : Symbol(Component, Decl(react.d.ts, 0, 25)) +>component : Symbol(Component.component, Decl(react.d.ts, 1, 21)) - class PureComponent {} ->PureComponent : Symbol(PureComponent, Decl(react.d.ts, 1, 22)) + class PureComponent { pure: string } +>PureComponent : Symbol(PureComponent, Decl(react.d.ts, 1, 41)) +>pure : Symbol(PureComponent.pure, Decl(react.d.ts, 2, 25)) } === main.js === @@ -17,9 +19,9 @@ declare namespace React { */ class C extends React.PureComponent {} >C : Symbol(C, Decl(main.js, 0, 0)) ->React.PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 1, 22)) +>React.PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 1, 41)) >React : Symbol(React, Decl(react.d.ts, 0, 0)) ->PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 1, 22)) +>PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 1, 41)) /** * @extends {React.Component} diff --git a/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.types b/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.types index 6af6602186f..bc49f04690e 100644 --- a/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.types +++ b/testdata/baselines/reference/compiler/jsdocExtendsClauseMismatch.types @@ -4,11 +4,13 @@ declare namespace React { >React : typeof React - class Component {} + class Component { component: string } >Component : Component +>component : string - class PureComponent {} + class PureComponent { pure: string } >PureComponent : PureComponent +>pure : string } === main.js === diff --git a/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts b/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts new file mode 100644 index 00000000000..dd480d7bb38 --- /dev/null +++ b/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts @@ -0,0 +1,10 @@ +// @noEmit: true + +declare class Base { +} +declare const StateDependencies_base: typeof Base; +/** + * @augments {Base} + */ +export declare class StateDependencies extends StateDependencies_base { +} diff --git a/testdata/tests/cases/compiler/jsdocExtendsClauseMismatch.ts b/testdata/tests/cases/compiler/jsdocExtendsClauseMismatch.ts index 68459184c2b..14f31320422 100644 --- a/testdata/tests/cases/compiler/jsdocExtendsClauseMismatch.ts +++ b/testdata/tests/cases/compiler/jsdocExtendsClauseMismatch.ts @@ -4,8 +4,8 @@ // @filename: react.d.ts declare namespace React { - class Component {} - class PureComponent {} + class Component { component: string } + class PureComponent { pure: string } } // @filename: main.js From 9710a73be39a6aca6f08c44cd8928576d95d0ffd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:35:21 +0000 Subject: [PATCH 3/7] Update JSDoc augments baselines Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com> --- ...TypeArgumentCount2(strict=true).errors.txt | 8 ++++++- .../compiler/jsExtendsImplicitAny.errors.txt | 8 ++++++- .../jsExtendsImplicitAny.errors.txt.diff | 22 +++++++++++-------- .../conformance/extendsTagEmit.errors.txt | 5 ++++- .../extendsTagEmit.errors.txt.diff | 19 ---------------- .../jsdocAugments_nameMismatch.errors.txt | 12 ---------- ...jsdocAugments_nameMismatch.errors.txt.diff | 16 ++++++++++++++ 7 files changed, 47 insertions(+), 43 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt index b114e4bfab2..31a6963472e 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt @@ -1,6 +1,8 @@ error TS5055: Cannot write file 'b.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +b.js(3,15): error TS2314: Generic type 'A' requires 1 type argument(s). b.js(4,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(17,15): error TS2314: Generic type 'A' requires 1 type argument(s). b.js(18,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -9,10 +11,12 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' ==== a.ts (0 errors) ==== export class A {} -==== b.js (2 errors) ==== +==== b.js (4 errors) ==== import { A } from './a.js'; /** @extends {A} */ + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). export class B1 extends A { ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -29,6 +33,8 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' } /** @extends {A} */ + ~~~~~~~~~~~~~~~~~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). export class B3 extends A { ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. diff --git a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt index 82c630fced8..6a0f6b58b2f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt @@ -1,24 +1,30 @@ /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +/b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). /b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +/b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). /b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== declare class A { x: T; } -==== /b.js (3 errors) ==== +==== /b.js (5 errors) ==== class B extends A {} ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; /** @augments A */ + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). class C extends A { } ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new C().x; /** @augments A */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). class D extends A {} ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. diff --git a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff index 135c21c2835..e4fe21b816f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff @@ -2,27 +2,31 @@ +++ new.jsExtendsImplicitAny.errors.txt @@= skipped -0, +0 lines =@@ /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. --/b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). --/b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). + /b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). +/b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. + /b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). +/b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== -@@= skipped -12, +12 lines =@@ - new B().x; + declare class A { x: T; } - /** @augments A */ -- ~ --!!! error TS2314: Generic type 'A' requires 1 type argument(s). +-==== /b.js (3 errors) ==== ++==== /b.js (5 errors) ==== + class B extends A {} + ~ + !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. +@@= skipped -15, +17 lines =@@ + ~ + !!! error TS2314: Generic type 'A' requires 1 type argument(s). class C extends A { } + ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new C().x; /** @augments A */ -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2314: Generic type 'A' requires 1 type argument(s). + ~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2314: Generic type 'A' requires 1 type argument(s). class D extends A {} + ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. diff --git a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt index 7f2002cbadb..6ab9c931111 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt @@ -1,13 +1,16 @@ +main.js(2,15): error TS2304: Cannot find name 'Mismatch'. main.js(2,15): error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. ==== super.js (0 errors) ==== export class B { } -==== main.js (1 errors) ==== +==== main.js (2 errors) ==== import { B } from './super' /** @extends {Mismatch} */ ~~~~~~~~ +!!! error TS2304: Cannot find name 'Mismatch'. + ~~~~~~~~ !!! error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. class C extends B { } diff --git a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt.diff deleted file mode 100644 index c87cc5fa7cc..00000000000 --- a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.extendsTagEmit.errors.txt -+++ new.extendsTagEmit.errors.txt -@@= skipped -0, +0 lines =@@ --main.js(2,15): error TS2304: Cannot find name 'Mismatch'. - main.js(2,15): error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. - - - ==== super.js (0 errors) ==== - export class B { } - --==== main.js (2 errors) ==== -+==== main.js (1 errors) ==== - import { B } from './super' - /** @extends {Mismatch} */ -- ~~~~~~~~ --!!! error TS2304: Cannot find name 'Mismatch'. - ~~~~~~~~ - !!! error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. - class C extends B { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt deleted file mode 100644 index f6d9d882101..00000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -/b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. - - -==== /b.js (1 errors) ==== - class A {} - class B {} - - /** @augments A */ - ~ -!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. - class C extends B {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff new file mode 100644 index 00000000000..06ecd4d26b4 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsdocAugments_nameMismatch.errors.txt ++++ new.jsdocAugments_nameMismatch.errors.txt +@@= skipped -0, +0 lines =@@ +-/b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. +- +- +-==== /b.js (1 errors) ==== +- class A {} +- class B {} +- +- /** @augments A */ +- ~ +-!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. +- class C extends B {} +- ++ \ No newline at end of file From 3424a8675648e73c2b0a8c498c8f8da1b934e7d0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:40:28 +0000 Subject: [PATCH 4/7] Preserve JSDoc source file lookup Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com> --- internal/checker/checker.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 043299896e7..5c9ace91dc8 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -4401,7 +4401,8 @@ func (c *Checker) checkClassLikeDeclaration(node *ast.Node) { } func (c *Checker) checkJSDocAugmentsTagMatchesExtends(node *ast.Node, baseTypeNode *ast.ExpressionWithTypeArgumentsNode, baseType *Type) { - for _, j := range node.EagerJSDoc(nil) { + file := ast.GetSourceFileOfNode(node) + for _, j := range node.EagerJSDoc(file) { if j.AsJSDoc().Tags == nil { continue } From 489ab5650172a7b8999fc9a48e52c87333ba0e5c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Aug 2026 20:45:56 +0000 Subject: [PATCH 5/7] Limit JSDoc augments checks to JS Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com> --- internal/checker/checker.go | 3 +++ .../compiler/jsdocAugmentsAliasExtends.symbols | 16 +++++++++++++--- .../compiler/jsdocAugmentsAliasExtends.types | 10 ++++++++++ .../cases/compiler/jsdocAugmentsAliasExtends.ts | 7 +++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 5c9ace91dc8..a53180b6368 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -4401,6 +4401,9 @@ func (c *Checker) checkClassLikeDeclaration(node *ast.Node) { } func (c *Checker) checkJSDocAugmentsTagMatchesExtends(node *ast.Node, baseTypeNode *ast.ExpressionWithTypeArgumentsNode, baseType *Type) { + if !ast.IsInJSFile(node) { + return + } file := ast.GetSourceFileOfNode(node) for _, j := range node.EagerJSDoc(file) { if j.AsJSDoc().Tags == nil { diff --git a/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols index d6d31e42cf6..9e2a4b6b622 100644 --- a/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols +++ b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.symbols @@ -4,15 +4,25 @@ declare class Base { >Base : Symbol(Base, Decl(jsdocAugmentsAliasExtends.ts, 0, 0)) } +declare class Other { +>Other : Symbol(Other, Decl(jsdocAugmentsAliasExtends.ts, 1, 1)) +} declare const StateDependencies_base: typeof Base; ->StateDependencies_base : Symbol(StateDependencies_base, Decl(jsdocAugmentsAliasExtends.ts, 2, 13)) +>StateDependencies_base : Symbol(StateDependencies_base, Decl(jsdocAugmentsAliasExtends.ts, 4, 13)) >Base : Symbol(Base, Decl(jsdocAugmentsAliasExtends.ts, 0, 0)) /** * @augments {Base} */ export declare class StateDependencies extends StateDependencies_base { ->StateDependencies : Symbol(StateDependencies, Decl(jsdocAugmentsAliasExtends.ts, 2, 50)) ->StateDependencies_base : Symbol(StateDependencies_base, Decl(jsdocAugmentsAliasExtends.ts, 2, 13)) +>StateDependencies : Symbol(StateDependencies, Decl(jsdocAugmentsAliasExtends.ts, 4, 50)) +>StateDependencies_base : Symbol(StateDependencies_base, Decl(jsdocAugmentsAliasExtends.ts, 4, 13)) +} +/** + * @augments {Base} + */ +export declare class TypeScriptStateDependencies extends Other { +>TypeScriptStateDependencies : Symbol(TypeScriptStateDependencies, Decl(jsdocAugmentsAliasExtends.ts, 9, 1)) +>Other : Symbol(Other, Decl(jsdocAugmentsAliasExtends.ts, 1, 1)) } diff --git a/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types index 80cbd00936d..ab30f8bb1d7 100644 --- a/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types +++ b/testdata/baselines/reference/compiler/jsdocAugmentsAliasExtends.types @@ -4,6 +4,9 @@ declare class Base { >Base : Base } +declare class Other { +>Other : Other +} declare const StateDependencies_base: typeof Base; >StateDependencies_base : typeof Base >Base : typeof Base @@ -15,4 +18,11 @@ export declare class StateDependencies extends StateDependencies_base { >StateDependencies : StateDependencies >StateDependencies_base : Base } +/** + * @augments {Base} + */ +export declare class TypeScriptStateDependencies extends Other { +>TypeScriptStateDependencies : TypeScriptStateDependencies +>Other : Other +} diff --git a/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts b/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts index dd480d7bb38..dc77e4f15bd 100644 --- a/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts +++ b/testdata/tests/cases/compiler/jsdocAugmentsAliasExtends.ts @@ -2,9 +2,16 @@ declare class Base { } +declare class Other { +} declare const StateDependencies_base: typeof Base; /** * @augments {Base} */ export declare class StateDependencies extends StateDependencies_base { } +/** + * @augments {Base} + */ +export declare class TypeScriptStateDependencies extends Other { +} From 5098c0b5235c7080691ed03168135d5a7a7c9c6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Aug 2026 23:45:44 +0000 Subject: [PATCH 6/7] Make JSDoc augments mismatch types distinct Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com> --- .../jsdocAugments_nameMismatch.errors.txt | 16 +++++++++++ ...jsdocAugments_nameMismatch.errors.txt.diff | 23 ++++++++------- .../jsdocAugments_nameMismatch.symbols | 17 +++++++---- .../jsdocAugments_nameMismatch.symbols.diff | 28 +++++++++++++++++++ .../jsdocAugments_nameMismatch.types | 13 +++++++-- .../jsdocAugments_nameMismatch.types.diff | 22 ++++++++++++++- 6 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt new file mode 100644 index 00000000000..6ce8977b56c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt @@ -0,0 +1,16 @@ +/b.js(8,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. + + +==== /b.js (1 errors) ==== + class A { + a = 1; + } + class B { + b = 2; + } + + /** @augments A */ + ~ +!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. + class C extends B {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff index 06ecd4d26b4..655a165f457 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff @@ -2,15 +2,18 @@ +++ new.jsdocAugments_nameMismatch.errors.txt @@= skipped -0, +0 lines =@@ -/b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. -- -- --==== /b.js (1 errors) ==== ++/b.js(8,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. + + + ==== /b.js (1 errors) ==== - class A {} - class B {} -- -- /** @augments A */ -- ~ --!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. -- class C extends B {} -- -+ \ No newline at end of file ++ class A { ++ a = 1; ++ } ++ class B { ++ b = 2; ++ } + + /** @augments A */ + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols index ecbdb0b2d07..66f1a7d807b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols @@ -1,14 +1,21 @@ //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// === /b.js === -class A {} +class A { >A : Symbol(A, Decl(b.js, 0, 0)) -class B {} ->B : Symbol(B, Decl(b.js, 0, 10)) + a = 1; +>a : Symbol(A.a, Decl(b.js, 0, 9)) +} +class B { +>B : Symbol(B, Decl(b.js, 2, 1)) + + b = 2; +>b : Symbol(B.b, Decl(b.js, 3, 9)) +} /** @augments A */ class C extends B {} ->C : Symbol(C, Decl(b.js, 1, 10)) ->B : Symbol(B, Decl(b.js, 0, 10)) +>C : Symbol(C, Decl(b.js, 5, 1)) +>B : Symbol(B, Decl(b.js, 2, 1)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff new file mode 100644 index 00000000000..8b619dbd92d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff @@ -0,0 +1,28 @@ +--- old.jsdocAugments_nameMismatch.symbols ++++ new.jsdocAugments_nameMismatch.symbols +@@= skipped -0, +0 lines =@@ + //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// + + === /b.js === +-class A {} ++class A { + >A : Symbol(A, Decl(b.js, 0, 0)) + +-class B {} +->B : Symbol(B, Decl(b.js, 0, 10)) ++ a = 1; ++>a : Symbol(A.a, Decl(b.js, 0, 9)) ++} ++class B { ++>B : Symbol(B, Decl(b.js, 2, 1)) ++ ++ b = 2; ++>b : Symbol(B.b, Decl(b.js, 3, 9)) ++} + + /** @augments A */ + class C extends B {} +->C : Symbol(C, Decl(b.js, 1, 10)) +->B : Symbol(B, Decl(b.js, 0, 10)) ++>C : Symbol(C, Decl(b.js, 5, 1)) ++>B : Symbol(B, Decl(b.js, 2, 1)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types index ea58c2aa366..b8470eea184 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types @@ -1,12 +1,21 @@ //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// === /b.js === -class A {} +class A { >A : A -class B {} + a = 1; +>a : number +>1 : 1 +} +class B { >B : B + b = 2; +>b : number +>2 : 2 +} + /** @augments A */ class C extends B {} >C : C diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff index 034f03ced69..eaa3deb9cbf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff @@ -1,6 +1,26 @@ --- old.jsdocAugments_nameMismatch.types +++ new.jsdocAugments_nameMismatch.types -@@= skipped -9, +9 lines =@@ +@@= skipped -0, +0 lines =@@ + //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// + + === /b.js === +-class A {} ++class A { + >A : A + +-class B {} ++ a = 1; ++>a : number ++>1 : 1 ++} ++class B { + >B : B ++ ++ b = 2; ++>b : number ++>2 : 2 ++} + /** @augments A */ class C extends B {} >C : C From 849d4e380717aad66cf5c8757e4acd3e44b9e5e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Aug 2026 23:46:05 +0000 Subject: [PATCH 7/7] Revert "Make JSDoc augments mismatch types distinct" This reverts commit 5098c0b5235c7080691ed03168135d5a7a7c9c6a. Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com> --- .../jsdocAugments_nameMismatch.errors.txt | 16 ----------- ...jsdocAugments_nameMismatch.errors.txt.diff | 23 +++++++-------- .../jsdocAugments_nameMismatch.symbols | 17 ++++------- .../jsdocAugments_nameMismatch.symbols.diff | 28 ------------------- .../jsdocAugments_nameMismatch.types | 13 ++------- .../jsdocAugments_nameMismatch.types.diff | 22 +-------------- 6 files changed, 18 insertions(+), 101 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt deleted file mode 100644 index 6ce8977b56c..00000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -/b.js(8,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. - - -==== /b.js (1 errors) ==== - class A { - a = 1; - } - class B { - b = 2; - } - - /** @augments A */ - ~ -!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. - class C extends B {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff index 655a165f457..06ecd4d26b4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt.diff @@ -2,18 +2,15 @@ +++ new.jsdocAugments_nameMismatch.errors.txt @@= skipped -0, +0 lines =@@ -/b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. -+/b.js(8,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. - - - ==== /b.js (1 errors) ==== +- +- +-==== /b.js (1 errors) ==== - class A {} - class B {} -+ class A { -+ a = 1; -+ } -+ class B { -+ b = 2; -+ } - - /** @augments A */ - ~ \ No newline at end of file +- +- /** @augments A */ +- ~ +-!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. +- class C extends B {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols index 66f1a7d807b..ecbdb0b2d07 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols @@ -1,21 +1,14 @@ //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// === /b.js === -class A { +class A {} >A : Symbol(A, Decl(b.js, 0, 0)) - a = 1; ->a : Symbol(A.a, Decl(b.js, 0, 9)) -} -class B { ->B : Symbol(B, Decl(b.js, 2, 1)) - - b = 2; ->b : Symbol(B.b, Decl(b.js, 3, 9)) -} +class B {} +>B : Symbol(B, Decl(b.js, 0, 10)) /** @augments A */ class C extends B {} ->C : Symbol(C, Decl(b.js, 5, 1)) ->B : Symbol(B, Decl(b.js, 2, 1)) +>C : Symbol(C, Decl(b.js, 1, 10)) +>B : Symbol(B, Decl(b.js, 0, 10)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff deleted file mode 100644 index 8b619dbd92d..00000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.symbols.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.jsdocAugments_nameMismatch.symbols -+++ new.jsdocAugments_nameMismatch.symbols -@@= skipped -0, +0 lines =@@ - //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// - - === /b.js === --class A {} -+class A { - >A : Symbol(A, Decl(b.js, 0, 0)) - --class B {} -->B : Symbol(B, Decl(b.js, 0, 10)) -+ a = 1; -+>a : Symbol(A.a, Decl(b.js, 0, 9)) -+} -+class B { -+>B : Symbol(B, Decl(b.js, 2, 1)) -+ -+ b = 2; -+>b : Symbol(B.b, Decl(b.js, 3, 9)) -+} - - /** @augments A */ - class C extends B {} -->C : Symbol(C, Decl(b.js, 1, 10)) -->B : Symbol(B, Decl(b.js, 0, 10)) -+>C : Symbol(C, Decl(b.js, 5, 1)) -+>B : Symbol(B, Decl(b.js, 2, 1)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types index b8470eea184..ea58c2aa366 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types @@ -1,21 +1,12 @@ //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// === /b.js === -class A { +class A {} >A : A - a = 1; ->a : number ->1 : 1 -} -class B { +class B {} >B : B - b = 2; ->b : number ->2 : 2 -} - /** @augments A */ class C extends B {} >C : C diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff index eaa3deb9cbf..034f03ced69 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.types.diff @@ -1,26 +1,6 @@ --- old.jsdocAugments_nameMismatch.types +++ new.jsdocAugments_nameMismatch.types -@@= skipped -0, +0 lines =@@ - //// [tests/cases/conformance/jsdoc/jsdocAugments_nameMismatch.ts] //// - - === /b.js === --class A {} -+class A { - >A : A - --class B {} -+ a = 1; -+>a : number -+>1 : 1 -+} -+class B { - >B : B -+ -+ b = 2; -+>b : number -+>2 : 2 -+} - +@@= skipped -9, +9 lines =@@ /** @augments A */ class C extends B {} >C : C