-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fixes to @augments handling #18775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes to @augments handling #18775
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1856,6 +1856,12 @@ namespace ts { | |
case CharacterCodes.closeBracket: | ||
pos++; | ||
return token = SyntaxKind.CloseBracketToken; | ||
case CharacterCodes.lessThan: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make sure that we have some tests that use < and > inside jsdoc comments in various places? it should be allowed everywhere in comment text, especially in misaligned cases like
And of course it should cause error in places like the tag name, etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test. |
||
pos++; | ||
return token = SyntaxKind.LessThanToken; | ||
case CharacterCodes.greaterThan: | ||
pos++; | ||
return token = SyntaxKind.GreaterThanToken; | ||
case CharacterCodes.equals: | ||
pos++; | ||
return token = SyntaxKind.EqualsToken; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2161,7 +2161,7 @@ namespace ts { | |
|
||
export interface JSDocAugmentsTag extends JSDocTag { | ||
kind: SyntaxKind.JSDocAugmentsTag; | ||
typeExpression: JSDocTypeExpression; | ||
class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't you want a subclass of ExpressionWithTypeArguments that has the override There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is intersection permissive where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot that |
||
} | ||
|
||
export interface JSDocClassTag extends JSDocTag { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"kind": "JSDocComment", | ||
"pos": 0, | ||
"end": 61, | ||
"tags": { | ||
"0": { | ||
"kind": "JSDocParameterTag", | ||
"pos": 7, | ||
"end": 16, | ||
"atToken": { | ||
"kind": "AtToken", | ||
"pos": 7, | ||
"end": 8 | ||
}, | ||
"tagName": { | ||
"kind": "Identifier", | ||
"pos": 8, | ||
"end": 13, | ||
"escapedText": "param" | ||
}, | ||
"name": { | ||
"kind": "Identifier", | ||
"pos": 14, | ||
"end": 15, | ||
"escapedText": "x" | ||
}, | ||
"isNameFirst": true, | ||
"isBracketed": false, | ||
"comment": "hi\n< > still part of the previous comment" | ||
}, | ||
"length": 1, | ||
"pos": 7, | ||
"end": 16 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
/a.js(2,14): error TS1005: '{' expected. | ||
/a.js(2,14): error TS1003: Identifier expected. | ||
/a.js(2,14): error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. | ||
/a.js(5,14): error TS2339: Property 'x' does not exist on type 'B'. | ||
|
||
|
||
==== /a.js (1 errors) ==== | ||
==== /a.js (3 errors) ==== | ||
class A { constructor() { this.x = 0; } } | ||
/** @augments */ | ||
~ | ||
!!! error TS1005: '{' expected. | ||
|
||
!!! error TS1003: Identifier expected. | ||
|
||
!!! error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. | ||
class B extends A { | ||
m() { | ||
this.x | ||
~ | ||
!!! error TS2339: Property 'x' does not exist on type 'B'. | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/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 {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
=== /b.js === | ||
class A {} | ||
>A : Symbol(A, Decl(b.js, 0, 0)) | ||
|
||
class B {} | ||
>B : Symbol(B, Decl(b.js, 0, 10)) | ||
|
||
/** @augments A */ | ||
class C extends B {} | ||
>C : Symbol(C, Decl(b.js, 1, 10)) | ||
>B : Symbol(B, Decl(b.js, 0, 10)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
=== /b.js === | ||
class A {} | ||
>A : A | ||
|
||
class B {} | ||
>B : B | ||
|
||
/** @augments A */ | ||
class C extends B {} | ||
>C : C | ||
>B : A | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
=== /b.js === | ||
class A { constructor() { this.x = 0; } } | ||
>A : Symbol(A, Decl(b.js, 0, 0)) | ||
>this.x : Symbol(A.x, Decl(b.js, 0, 25)) | ||
>this : Symbol(A, Decl(b.js, 0, 0)) | ||
>x : Symbol(A.x, Decl(b.js, 0, 25)) | ||
|
||
/** @augments A */ | ||
class B { | ||
>B : Symbol(B, Decl(b.js, 0, 41)) | ||
|
||
m() { | ||
>m : Symbol(B.m, Decl(b.js, 3, 9)) | ||
|
||
return this.x; | ||
>this.x : Symbol(A.x, Decl(b.js, 0, 25)) | ||
>this : Symbol(B, Decl(b.js, 0, 41)) | ||
>x : Symbol(A.x, Decl(b.js, 0, 25)) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this message mention class expressions?