Skip to content

Commit ca1bfda

Browse files
author
Andy Hanson
committed
Renames and diagnostic changes
1 parent 41e239d commit ca1bfda

6 files changed

+18
-16
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19790,25 +19790,27 @@ namespace ts {
1979019790
}
1979119791

1979219792
function checkJSDocAugmentsTag(node: JSDocAugmentsTag): void {
19793-
const cls = getNodeCommentedByJSDocTag(node);
19793+
const cls = getJSDocHost(node);
1979419794
if (!isClassDeclaration(cls) && !isClassExpression(cls)) {
19795-
error(cls, Diagnostics.JSDoc_augments_tag_will_be_ignored_if_not_attached_to_a_class_declaration);
19795+
error(cls, Diagnostics.JSDoc_augments_is_not_attached_to_a_class_declaration);
1979619796
return;
1979719797
}
1979819798

19799-
const name = node.class.expression.kind === SyntaxKind.PropertyAccessExpression ? node.class.expression.name : node.class.expression;
19799+
const name = getIdentifierFromEntityNameExpression(node.class.expression);
1980019800
const extend = getClassExtendsHeritageClauseElement(cls);
1980119801
if (extend) {
19802-
const className = getClassName(extend.expression);
19802+
const className = getIdentifierFromEntityNameExpression(extend.expression);
1980319803
if (className && name.escapedText !== className.escapedText) {
19804-
error(name, Diagnostics.JSDoc_augments_tag_declares_to_extend_0_but_actual_class_augments_1,
19804+
error(name, Diagnostics.JSDoc_augments_0_does_not_match_the_extends_1_clause,
1980519805
unescapeLeadingUnderscores(name.escapedText),
1980619806
unescapeLeadingUnderscores(className.escapedText));
1980719807
}
1980819808
}
1980919809
}
1981019810

19811-
function getClassName(node: Expression): Identifier | undefined {
19811+
function getIdentifierFromEntityNameExpression(node: Identifier | PropertyAccessExpression): Identifier;
19812+
function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined;
19813+
function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined {
1981219814
switch (node.kind) {
1981319815
case SyntaxKind.Identifier:
1981419816
return node as Identifier;

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,11 +3511,11 @@
35113511
"category": "Error",
35123512
"code": 8021
35133513
},
3514-
"JSDoc '@augments' tag will be ignored if not attached to a class declaration.": {
3514+
"JSDoc '@augments' is not attached to a class declaration.": {
35153515
"category": "Error",
35163516
"code": 8022
35173517
},
3518-
"JSDoc '@augments' tag declares to extend '{0}', but actual class augments '{1}'.": {
3518+
"JSDoc '@augments {0}' does not match the 'extends {1}' clause.": {
35193519
"category": "Error",
35203520
"code": 8023
35213521
},

src/compiler/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ namespace ts {
15811581
return undefined;
15821582
}
15831583
const name = node.name.escapedText;
1584-
const func = getNodeCommentedByJSDocTag(node);
1584+
const func = getJSDocHost(node);
15851585
if (!isFunctionLike(func)) {
15861586
return undefined;
15871587
}
@@ -1590,7 +1590,7 @@ namespace ts {
15901590
return parameter && parameter.symbol;
15911591
}
15921592

1593-
export function getNodeCommentedByJSDocTag(node: JSDocTag): Node {
1593+
export function getJSDocHost(node: JSDocTag): Node {
15941594
Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment);
15951595
return node.parent!.parent!;
15961596
}

tests/baselines/reference/jsdocAugmentsMissingType.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/a.js(2,14): error TS1003: Identifier expected.
2-
/a.js(2,14): error TS8023: JSDoc '@augments' tag declares to extend '', but actual class augments 'A'.
2+
/a.js(2,14): error TS8023: JSDoc '@augments ' does not match the 'extends A' clause.
33
/a.js(5,14): error TS2339: Property 'x' does not exist on type 'B'.
44

55

@@ -9,7 +9,7 @@
99

1010
!!! error TS1003: Identifier expected.
1111

12-
!!! error TS8023: JSDoc '@augments' tag declares to extend '', but actual class augments 'A'.
12+
!!! error TS8023: JSDoc '@augments ' does not match the 'extends A' clause.
1313
class B extends A {
1414
m() {
1515
this.x
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/b.js(4,15): error TS8023: JSDoc '@augments' tag declares to extend 'A', but actual class augments 'B'.
1+
/b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause.
22

33

44
==== /b.js (1 errors) ====
@@ -7,6 +7,6 @@
77

88
/** @augments A */
99
~
10-
!!! error TS8023: JSDoc '@augments' tag declares to extend 'A', but actual class augments 'B'.
10+
!!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause.
1111
class C extends B {}
1212

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/b.js(3,10): error TS8022: JSDoc '@augments' tag will be ignored if not attached to a class declaration.
1+
/b.js(3,10): error TS8022: JSDoc '@augments' is not attached to a class declaration.
22

33

44
==== /b.js (1 errors) ====
55
class A {}
66
/** @augments A */
77
function b() {}
88
~
9-
!!! error TS8022: JSDoc '@augments' tag will be ignored if not attached to a class declaration.
9+
!!! error TS8022: JSDoc '@augments' is not attached to a class declaration.
1010

0 commit comments

Comments
 (0)