mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 16:39:46 -05:00
Support parsing @template {T} in addition to @template T (#21270)
This commit is contained in:
@@ -6830,7 +6830,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseTemplateTag(atToken: AtToken, tagName: Identifier): JSDocTemplateTag | undefined {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) {
|
||||
if (some(tags, isJSDocTemplateTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.escapedText);
|
||||
}
|
||||
|
||||
@@ -6839,14 +6839,14 @@ namespace ts {
|
||||
const typeParametersPos = getNodePos();
|
||||
|
||||
while (true) {
|
||||
const name = parseJSDocIdentifierName();
|
||||
const typeParameter = <TypeParameterDeclaration>createNode(SyntaxKind.TypeParameter);
|
||||
const name = parseJSDocIdentifierNameWithOptionalBraces();
|
||||
skipWhitespace();
|
||||
if (!name) {
|
||||
parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const typeParameter = <TypeParameterDeclaration>createNode(SyntaxKind.TypeParameter, name.pos);
|
||||
typeParameter.name = name;
|
||||
finishNode(typeParameter);
|
||||
|
||||
@@ -6869,6 +6869,15 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseJSDocIdentifierNameWithOptionalBraces(): Identifier | undefined {
|
||||
const parsedBrace = parseOptional(SyntaxKind.OpenBraceToken);
|
||||
const res = parseJSDocIdentifierName();
|
||||
if (parsedBrace) {
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function nextJSDocToken(): JsDocSyntaxKind {
|
||||
return currentToken = scanner.scanJSDocToken();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
],
|
||||
"documentation": [
|
||||
{
|
||||
"text": "DocT} A template",
|
||||
"text": "Doc",
|
||||
"kind": "text"
|
||||
}
|
||||
],
|
||||
@@ -76,6 +76,10 @@
|
||||
"name": "augments",
|
||||
"text": "C<T> Augments it"
|
||||
},
|
||||
{
|
||||
"name": "template",
|
||||
"text": "{T} A template"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"text": "{number | string} A type"
|
||||
|
||||
Reference in New Issue
Block a user