diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index cb3305849219b..ada4288903271 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1081,6 +1081,10 @@ namespace ts { return currentToken = scanner.scan(); } + function nextTokenJSDoc(): JSDocSyntaxKind { + return currentToken = scanner.scanJsDocToken(); + } + function reScanGreaterToken(): SyntaxKind { return currentToken = scanner.reScanGreaterToken(); } @@ -1198,6 +1202,15 @@ namespace ts { return false; } + function parseExpectedJSDoc(kind: JSDocSyntaxKind) { + if (token() === kind) { + nextTokenJSDoc(); + return true; + } + parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(kind)); + return false; + } + function parseOptional(t: SyntaxKind): boolean { if (token() === t) { nextToken(); @@ -1214,18 +1227,38 @@ namespace ts { return undefined; } + function parseOptionalTokenJSDoc(t: TKind): Token; + function parseOptionalTokenJSDoc(t: JSDocSyntaxKind): Node | undefined { + if (token() === t) { + return parseTokenNodeJSDoc(); + } + return undefined; + } + function parseExpectedToken(t: TKind, diagnosticMessage?: DiagnosticMessage, arg0?: any): Token; function parseExpectedToken(t: SyntaxKind, diagnosticMessage?: DiagnosticMessage, arg0?: any): Node { return parseOptionalToken(t) || createMissingNode(t, /*reportAtCurrentPosition*/ false, diagnosticMessage || Diagnostics._0_expected, arg0 || tokenToString(t)); } + function parseExpectedTokenJSDoc(t: TKind): Token; + function parseExpectedTokenJSDoc(t: JSDocSyntaxKind): Node { + return parseOptionalTokenJSDoc(t) || + createMissingNode(t, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(t)); + } + function parseTokenNode(): T { const node = createNode(token()); nextToken(); return finishNode(node); } + function parseTokenNodeJSDoc(): T { + const node = createNode(token()); + nextTokenJSDoc(); + return finishNode(node); + } + function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. if (token() === SyntaxKind.SemicolonToken) { @@ -6345,7 +6378,7 @@ namespace ts { const hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(SyntaxKind.OpenBraceToken); result.type = doInsideOfContext(NodeFlags.JSDoc, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(SyntaxKind.CloseBraceToken); + parseExpectedJSDoc(SyntaxKind.CloseBraceToken); } fixupParentReferences(result); @@ -6432,7 +6465,7 @@ namespace ts { indent += text.length; } - nextJSDocToken(); + nextTokenJSDoc(); while (parseOptionalJsdoc(SyntaxKind.WhitespaceTrivia)); if (parseOptionalJsdoc(SyntaxKind.NewLineTrivia)) { state = JSDocState.BeginningOfLine; @@ -6493,7 +6526,7 @@ namespace ts { pushComment(scanner.getTokenText()); break; } - nextJSDocToken(); + nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); @@ -6522,7 +6555,7 @@ namespace ts { function isNextNonwhitespaceTokenEndOfFile(): boolean { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { - nextJSDocToken(); + nextTokenJSDoc(); if (token() === SyntaxKind.EndOfFileToken) { return true; } @@ -6539,7 +6572,7 @@ namespace ts { } } while (token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia) { - nextJSDocToken(); + nextTokenJSDoc(); } } @@ -6563,7 +6596,7 @@ namespace ts { else if (token() === SyntaxKind.AsteriskToken) { precedingLineBreak = false; } - nextJSDocToken(); + nextTokenJSDoc(); } return seenLineBreak ? indentText : ""; } @@ -6571,7 +6604,7 @@ namespace ts { function parseTag(margin: number) { Debug.assert(token() === SyntaxKind.AtToken); const start = scanner.getTokenPos(); - nextJSDocToken(); + nextTokenJSDoc(); const tagName = parseJSDocIdentifierName(/*message*/ undefined); const indentText = skipWhitespaceOrAsterisk(); @@ -6643,7 +6676,7 @@ namespace ts { pushComment(initialMargin); state = JSDocState.SavingComments; } - let tok = token() as JsDocSyntaxKind; + let tok = token() as JSDocSyntaxKind; loop: while (true) { switch (tok) { case SyntaxKind.NewLineTrivia: @@ -6674,11 +6707,11 @@ namespace ts { break; case SyntaxKind.OpenBraceToken: state = JSDocState.SavingComments; - if (lookAhead(() => nextJSDocToken() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link")) { + if (lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link")) { pushComment(scanner.getTokenText()); - nextJSDocToken(); + nextTokenJSDoc(); pushComment(scanner.getTokenText()); - nextJSDocToken(); + nextTokenJSDoc(); } pushComment(scanner.getTokenText()); break; @@ -6696,7 +6729,7 @@ namespace ts { pushComment(scanner.getTokenText()); break; } - tok = nextJSDocToken(); + tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -6730,16 +6763,19 @@ namespace ts { } function parseBracketNameInPropertyAndParamTag(): { name: EntityName, isBracketed: boolean } { - if (token() === SyntaxKind.NoSubstitutionTemplateLiteral) { - // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false }; - } // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - const isBracketed = parseOptional(SyntaxKind.OpenBracketToken); + const isBracketed = parseOptionalJsdoc(SyntaxKind.OpenBracketToken); + if (isBracketed) { + skipWhitespace(); + } + // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild + const isBackquoted = parseOptionalJsdoc(SyntaxKind.BacktickToken); const name = parseJSDocEntityName(); + if (isBackquoted) { + parseExpectedTokenJSDoc(SyntaxKind.BacktickToken); + } if (isBracketed) { skipWhitespace(); - // May have an optional default, e.g. '[foo = 42]' if (parseOptionalToken(SyntaxKind.EqualsToken)) { parseExpression(); @@ -7022,7 +7058,7 @@ namespace ts { let canParseTag = true; let seenAsterisk = false; while (true) { - switch (nextJSDocToken()) { + switch (nextTokenJSDoc()) { case SyntaxKind.AtToken: if (canParseTag) { const child = tryParseChildTag(target, indent); @@ -7057,7 +7093,7 @@ namespace ts { function tryParseChildTag(target: PropertyLikeParse, indent: number): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false { Debug.assert(token() === SyntaxKind.AtToken); const start = scanner.getStartPos(); - nextJSDocToken(); + nextTokenJSDoc(); const tagName = parseJSDocIdentifierName(); skipWhitespace(); @@ -7109,13 +7145,9 @@ namespace ts { return result; } - function nextJSDocToken(): JsDocSyntaxKind { - return currentToken = scanner.scanJSDocToken(); - } - - function parseOptionalJsdoc(t: JsDocSyntaxKind): boolean { + function parseOptionalJsdoc(t: JSDocSyntaxKind): boolean { if (token() === t) { - nextJSDocToken(); + nextTokenJSDoc(); return true; } return false; @@ -7150,7 +7182,7 @@ namespace ts { result.escapedText = escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - nextJSDocToken(); + nextTokenJSDoc(); return result; } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index e31876962b7da..36ac8adfa9053 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -33,7 +33,7 @@ namespace ts { reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; - scanJSDocToken(): JsDocSyntaxKind; + scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; getText(): string; // Sets the text for the scanner to scan. An optional subrange starting point and length @@ -886,7 +886,7 @@ namespace ts { reScanJsxToken, reScanLessThanToken, scanJsxToken, - scanJSDocToken, + scanJsDocToken, scan, getText, setText, @@ -2050,7 +2050,7 @@ namespace ts { } } - function scanJSDocToken(): JsDocSyntaxKind { + function scanJsDocToken(): JSDocSyntaxKind { startPos = tokenPos = pos; tokenFlags = 0; if (pos >= end) { @@ -2093,12 +2093,7 @@ namespace ts { case CharacterCodes.dot: return token = SyntaxKind.DotToken; case CharacterCodes.backtick: - while (pos < end && text.charCodeAt(pos) !== CharacterCodes.backtick) { - pos++; - } - tokenValue = text.substring(tokenPos + 1, pos); - pos++; - return token = SyntaxKind.NoSubstitutionTemplateLiteral; + return token = SyntaxKind.BacktickToken; } if (isIdentifierStart(ch, ScriptTarget.Latest)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f9ad5ba15707d..826c567b06fbd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -8,7 +8,7 @@ namespace ts { end: number; } - export type JsDocSyntaxKind = + export type JSDocSyntaxKind = | SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken @@ -23,7 +23,7 @@ namespace ts { | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier - | SyntaxKind.NoSubstitutionTemplateLiteral + | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; @@ -181,6 +181,8 @@ namespace ts { QuestionToken, ColonToken, AtToken, + /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ + BacktickToken, // Assignments EqualsToken, PlusEqualsToken, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json index 1d515fd8eb069..24779f14f89e0 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json @@ -8,7 +8,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 29, + "end": 32, "modifierFlagsCache": 0, "transformFlags": 0, "tagName": { @@ -46,6 +46,6 @@ }, "length": 1, "pos": 8, - "end": 29 + "end": 32 } } \ No newline at end of file diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index e055f5b802db5..1b4acd88ebf79 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -72,7 +72,7 @@ declare namespace ts { pos: number; end: number; } - type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; + type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { @@ -135,281 +135,283 @@ declare namespace ts { QuestionToken = 56, ColonToken = 57, AtToken = 58, - EqualsToken = 59, - PlusEqualsToken = 60, - MinusEqualsToken = 61, - AsteriskEqualsToken = 62, - AsteriskAsteriskEqualsToken = 63, - SlashEqualsToken = 64, - PercentEqualsToken = 65, - LessThanLessThanEqualsToken = 66, - GreaterThanGreaterThanEqualsToken = 67, - GreaterThanGreaterThanGreaterThanEqualsToken = 68, - AmpersandEqualsToken = 69, - BarEqualsToken = 70, - CaretEqualsToken = 71, - Identifier = 72, - BreakKeyword = 73, - CaseKeyword = 74, - CatchKeyword = 75, - ClassKeyword = 76, - ConstKeyword = 77, - ContinueKeyword = 78, - DebuggerKeyword = 79, - DefaultKeyword = 80, - DeleteKeyword = 81, - DoKeyword = 82, - ElseKeyword = 83, - EnumKeyword = 84, - ExportKeyword = 85, - ExtendsKeyword = 86, - FalseKeyword = 87, - FinallyKeyword = 88, - ForKeyword = 89, - FunctionKeyword = 90, - IfKeyword = 91, - ImportKeyword = 92, - InKeyword = 93, - InstanceOfKeyword = 94, - NewKeyword = 95, - NullKeyword = 96, - ReturnKeyword = 97, - SuperKeyword = 98, - SwitchKeyword = 99, - ThisKeyword = 100, - ThrowKeyword = 101, - TrueKeyword = 102, - TryKeyword = 103, - TypeOfKeyword = 104, - VarKeyword = 105, - VoidKeyword = 106, - WhileKeyword = 107, - WithKeyword = 108, - ImplementsKeyword = 109, - InterfaceKeyword = 110, - LetKeyword = 111, - PackageKeyword = 112, - PrivateKeyword = 113, - ProtectedKeyword = 114, - PublicKeyword = 115, - StaticKeyword = 116, - YieldKeyword = 117, - AbstractKeyword = 118, - AsKeyword = 119, - AnyKeyword = 120, - AsyncKeyword = 121, - AwaitKeyword = 122, - BooleanKeyword = 123, - ConstructorKeyword = 124, - DeclareKeyword = 125, - GetKeyword = 126, - InferKeyword = 127, - IsKeyword = 128, - KeyOfKeyword = 129, - ModuleKeyword = 130, - NamespaceKeyword = 131, - NeverKeyword = 132, - ReadonlyKeyword = 133, - RequireKeyword = 134, - NumberKeyword = 135, - ObjectKeyword = 136, - SetKeyword = 137, - StringKeyword = 138, - SymbolKeyword = 139, - TypeKeyword = 140, - UndefinedKeyword = 141, - UniqueKeyword = 142, - UnknownKeyword = 143, - FromKeyword = 144, - GlobalKeyword = 145, - BigIntKeyword = 146, - OfKeyword = 147, - QualifiedName = 148, - ComputedPropertyName = 149, - TypeParameter = 150, - Parameter = 151, - Decorator = 152, - PropertySignature = 153, - PropertyDeclaration = 154, - MethodSignature = 155, - MethodDeclaration = 156, - Constructor = 157, - GetAccessor = 158, - SetAccessor = 159, - CallSignature = 160, - ConstructSignature = 161, - IndexSignature = 162, - TypePredicate = 163, - TypeReference = 164, - FunctionType = 165, - ConstructorType = 166, - TypeQuery = 167, - TypeLiteral = 168, - ArrayType = 169, - TupleType = 170, - OptionalType = 171, - RestType = 172, - UnionType = 173, - IntersectionType = 174, - ConditionalType = 175, - InferType = 176, - ParenthesizedType = 177, - ThisType = 178, - TypeOperator = 179, - IndexedAccessType = 180, - MappedType = 181, - LiteralType = 182, - ImportType = 183, - ObjectBindingPattern = 184, - ArrayBindingPattern = 185, - BindingElement = 186, - ArrayLiteralExpression = 187, - ObjectLiteralExpression = 188, - PropertyAccessExpression = 189, - ElementAccessExpression = 190, - CallExpression = 191, - NewExpression = 192, - TaggedTemplateExpression = 193, - TypeAssertionExpression = 194, - ParenthesizedExpression = 195, - FunctionExpression = 196, - ArrowFunction = 197, - DeleteExpression = 198, - TypeOfExpression = 199, - VoidExpression = 200, - AwaitExpression = 201, - PrefixUnaryExpression = 202, - PostfixUnaryExpression = 203, - BinaryExpression = 204, - ConditionalExpression = 205, - TemplateExpression = 206, - YieldExpression = 207, - SpreadElement = 208, - ClassExpression = 209, - OmittedExpression = 210, - ExpressionWithTypeArguments = 211, - AsExpression = 212, - NonNullExpression = 213, - MetaProperty = 214, - SyntheticExpression = 215, - TemplateSpan = 216, - SemicolonClassElement = 217, - Block = 218, - VariableStatement = 219, - EmptyStatement = 220, - ExpressionStatement = 221, - IfStatement = 222, - DoStatement = 223, - WhileStatement = 224, - ForStatement = 225, - ForInStatement = 226, - ForOfStatement = 227, - ContinueStatement = 228, - BreakStatement = 229, - ReturnStatement = 230, - WithStatement = 231, - SwitchStatement = 232, - LabeledStatement = 233, - ThrowStatement = 234, - TryStatement = 235, - DebuggerStatement = 236, - VariableDeclaration = 237, - VariableDeclarationList = 238, - FunctionDeclaration = 239, - ClassDeclaration = 240, - InterfaceDeclaration = 241, - TypeAliasDeclaration = 242, - EnumDeclaration = 243, - ModuleDeclaration = 244, - ModuleBlock = 245, - CaseBlock = 246, - NamespaceExportDeclaration = 247, - ImportEqualsDeclaration = 248, - ImportDeclaration = 249, - ImportClause = 250, - NamespaceImport = 251, - NamedImports = 252, - ImportSpecifier = 253, - ExportAssignment = 254, - ExportDeclaration = 255, - NamedExports = 256, - ExportSpecifier = 257, - MissingDeclaration = 258, - ExternalModuleReference = 259, - JsxElement = 260, - JsxSelfClosingElement = 261, - JsxOpeningElement = 262, - JsxClosingElement = 263, - JsxFragment = 264, - JsxOpeningFragment = 265, - JsxClosingFragment = 266, - JsxAttribute = 267, - JsxAttributes = 268, - JsxSpreadAttribute = 269, - JsxExpression = 270, - CaseClause = 271, - DefaultClause = 272, - HeritageClause = 273, - CatchClause = 274, - PropertyAssignment = 275, - ShorthandPropertyAssignment = 276, - SpreadAssignment = 277, - EnumMember = 278, - UnparsedPrologue = 279, - UnparsedPrepend = 280, - UnparsedText = 281, - UnparsedInternalText = 282, - UnparsedSyntheticReference = 283, - SourceFile = 284, - Bundle = 285, - UnparsedSource = 286, - InputFiles = 287, - JSDocTypeExpression = 288, - JSDocAllType = 289, - JSDocUnknownType = 290, - JSDocNullableType = 291, - JSDocNonNullableType = 292, - JSDocOptionalType = 293, - JSDocFunctionType = 294, - JSDocVariadicType = 295, - JSDocComment = 296, - JSDocTypeLiteral = 297, - JSDocSignature = 298, - JSDocTag = 299, - JSDocAugmentsTag = 300, - JSDocClassTag = 301, - JSDocCallbackTag = 302, - JSDocEnumTag = 303, - JSDocParameterTag = 304, - JSDocReturnTag = 305, - JSDocThisTag = 306, - JSDocTypeTag = 307, - JSDocTemplateTag = 308, - JSDocTypedefTag = 309, - JSDocPropertyTag = 310, - SyntaxList = 311, - NotEmittedStatement = 312, - PartiallyEmittedExpression = 313, - CommaListExpression = 314, - MergeDeclarationMarker = 315, - EndOfDeclarationMarker = 316, - Count = 317, - FirstAssignment = 59, - LastAssignment = 71, - FirstCompoundAssignment = 60, - LastCompoundAssignment = 71, - FirstReservedWord = 73, - LastReservedWord = 108, - FirstKeyword = 73, - LastKeyword = 147, - FirstFutureReservedWord = 109, - LastFutureReservedWord = 117, - FirstTypeNode = 163, - LastTypeNode = 183, + /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ + BacktickToken = 59, + EqualsToken = 60, + PlusEqualsToken = 61, + MinusEqualsToken = 62, + AsteriskEqualsToken = 63, + AsteriskAsteriskEqualsToken = 64, + SlashEqualsToken = 65, + PercentEqualsToken = 66, + LessThanLessThanEqualsToken = 67, + GreaterThanGreaterThanEqualsToken = 68, + GreaterThanGreaterThanGreaterThanEqualsToken = 69, + AmpersandEqualsToken = 70, + BarEqualsToken = 71, + CaretEqualsToken = 72, + Identifier = 73, + BreakKeyword = 74, + CaseKeyword = 75, + CatchKeyword = 76, + ClassKeyword = 77, + ConstKeyword = 78, + ContinueKeyword = 79, + DebuggerKeyword = 80, + DefaultKeyword = 81, + DeleteKeyword = 82, + DoKeyword = 83, + ElseKeyword = 84, + EnumKeyword = 85, + ExportKeyword = 86, + ExtendsKeyword = 87, + FalseKeyword = 88, + FinallyKeyword = 89, + ForKeyword = 90, + FunctionKeyword = 91, + IfKeyword = 92, + ImportKeyword = 93, + InKeyword = 94, + InstanceOfKeyword = 95, + NewKeyword = 96, + NullKeyword = 97, + ReturnKeyword = 98, + SuperKeyword = 99, + SwitchKeyword = 100, + ThisKeyword = 101, + ThrowKeyword = 102, + TrueKeyword = 103, + TryKeyword = 104, + TypeOfKeyword = 105, + VarKeyword = 106, + VoidKeyword = 107, + WhileKeyword = 108, + WithKeyword = 109, + ImplementsKeyword = 110, + InterfaceKeyword = 111, + LetKeyword = 112, + PackageKeyword = 113, + PrivateKeyword = 114, + ProtectedKeyword = 115, + PublicKeyword = 116, + StaticKeyword = 117, + YieldKeyword = 118, + AbstractKeyword = 119, + AsKeyword = 120, + AnyKeyword = 121, + AsyncKeyword = 122, + AwaitKeyword = 123, + BooleanKeyword = 124, + ConstructorKeyword = 125, + DeclareKeyword = 126, + GetKeyword = 127, + InferKeyword = 128, + IsKeyword = 129, + KeyOfKeyword = 130, + ModuleKeyword = 131, + NamespaceKeyword = 132, + NeverKeyword = 133, + ReadonlyKeyword = 134, + RequireKeyword = 135, + NumberKeyword = 136, + ObjectKeyword = 137, + SetKeyword = 138, + StringKeyword = 139, + SymbolKeyword = 140, + TypeKeyword = 141, + UndefinedKeyword = 142, + UniqueKeyword = 143, + UnknownKeyword = 144, + FromKeyword = 145, + GlobalKeyword = 146, + BigIntKeyword = 147, + OfKeyword = 148, + QualifiedName = 149, + ComputedPropertyName = 150, + TypeParameter = 151, + Parameter = 152, + Decorator = 153, + PropertySignature = 154, + PropertyDeclaration = 155, + MethodSignature = 156, + MethodDeclaration = 157, + Constructor = 158, + GetAccessor = 159, + SetAccessor = 160, + CallSignature = 161, + ConstructSignature = 162, + IndexSignature = 163, + TypePredicate = 164, + TypeReference = 165, + FunctionType = 166, + ConstructorType = 167, + TypeQuery = 168, + TypeLiteral = 169, + ArrayType = 170, + TupleType = 171, + OptionalType = 172, + RestType = 173, + UnionType = 174, + IntersectionType = 175, + ConditionalType = 176, + InferType = 177, + ParenthesizedType = 178, + ThisType = 179, + TypeOperator = 180, + IndexedAccessType = 181, + MappedType = 182, + LiteralType = 183, + ImportType = 184, + ObjectBindingPattern = 185, + ArrayBindingPattern = 186, + BindingElement = 187, + ArrayLiteralExpression = 188, + ObjectLiteralExpression = 189, + PropertyAccessExpression = 190, + ElementAccessExpression = 191, + CallExpression = 192, + NewExpression = 193, + TaggedTemplateExpression = 194, + TypeAssertionExpression = 195, + ParenthesizedExpression = 196, + FunctionExpression = 197, + ArrowFunction = 198, + DeleteExpression = 199, + TypeOfExpression = 200, + VoidExpression = 201, + AwaitExpression = 202, + PrefixUnaryExpression = 203, + PostfixUnaryExpression = 204, + BinaryExpression = 205, + ConditionalExpression = 206, + TemplateExpression = 207, + YieldExpression = 208, + SpreadElement = 209, + ClassExpression = 210, + OmittedExpression = 211, + ExpressionWithTypeArguments = 212, + AsExpression = 213, + NonNullExpression = 214, + MetaProperty = 215, + SyntheticExpression = 216, + TemplateSpan = 217, + SemicolonClassElement = 218, + Block = 219, + VariableStatement = 220, + EmptyStatement = 221, + ExpressionStatement = 222, + IfStatement = 223, + DoStatement = 224, + WhileStatement = 225, + ForStatement = 226, + ForInStatement = 227, + ForOfStatement = 228, + ContinueStatement = 229, + BreakStatement = 230, + ReturnStatement = 231, + WithStatement = 232, + SwitchStatement = 233, + LabeledStatement = 234, + ThrowStatement = 235, + TryStatement = 236, + DebuggerStatement = 237, + VariableDeclaration = 238, + VariableDeclarationList = 239, + FunctionDeclaration = 240, + ClassDeclaration = 241, + InterfaceDeclaration = 242, + TypeAliasDeclaration = 243, + EnumDeclaration = 244, + ModuleDeclaration = 245, + ModuleBlock = 246, + CaseBlock = 247, + NamespaceExportDeclaration = 248, + ImportEqualsDeclaration = 249, + ImportDeclaration = 250, + ImportClause = 251, + NamespaceImport = 252, + NamedImports = 253, + ImportSpecifier = 254, + ExportAssignment = 255, + ExportDeclaration = 256, + NamedExports = 257, + ExportSpecifier = 258, + MissingDeclaration = 259, + ExternalModuleReference = 260, + JsxElement = 261, + JsxSelfClosingElement = 262, + JsxOpeningElement = 263, + JsxClosingElement = 264, + JsxFragment = 265, + JsxOpeningFragment = 266, + JsxClosingFragment = 267, + JsxAttribute = 268, + JsxAttributes = 269, + JsxSpreadAttribute = 270, + JsxExpression = 271, + CaseClause = 272, + DefaultClause = 273, + HeritageClause = 274, + CatchClause = 275, + PropertyAssignment = 276, + ShorthandPropertyAssignment = 277, + SpreadAssignment = 278, + EnumMember = 279, + UnparsedPrologue = 280, + UnparsedPrepend = 281, + UnparsedText = 282, + UnparsedInternalText = 283, + UnparsedSyntheticReference = 284, + SourceFile = 285, + Bundle = 286, + UnparsedSource = 287, + InputFiles = 288, + JSDocTypeExpression = 289, + JSDocAllType = 290, + JSDocUnknownType = 291, + JSDocNullableType = 292, + JSDocNonNullableType = 293, + JSDocOptionalType = 294, + JSDocFunctionType = 295, + JSDocVariadicType = 296, + JSDocComment = 297, + JSDocTypeLiteral = 298, + JSDocSignature = 299, + JSDocTag = 300, + JSDocAugmentsTag = 301, + JSDocClassTag = 302, + JSDocCallbackTag = 303, + JSDocEnumTag = 304, + JSDocParameterTag = 305, + JSDocReturnTag = 306, + JSDocThisTag = 307, + JSDocTypeTag = 308, + JSDocTemplateTag = 309, + JSDocTypedefTag = 310, + JSDocPropertyTag = 311, + SyntaxList = 312, + NotEmittedStatement = 313, + PartiallyEmittedExpression = 314, + CommaListExpression = 315, + MergeDeclarationMarker = 316, + EndOfDeclarationMarker = 317, + Count = 318, + FirstAssignment = 60, + LastAssignment = 72, + FirstCompoundAssignment = 61, + LastCompoundAssignment = 72, + FirstReservedWord = 74, + LastReservedWord = 109, + FirstKeyword = 74, + LastKeyword = 148, + FirstFutureReservedWord = 110, + LastFutureReservedWord = 118, + FirstTypeNode = 164, + LastTypeNode = 184, FirstPunctuation = 18, - LastPunctuation = 71, + LastPunctuation = 72, FirstToken = 0, - LastToken = 147, + LastToken = 148, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -417,12 +419,12 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 28, - LastBinaryOperator = 71, - FirstNode = 148, - FirstJSDocNode = 288, - LastJSDocNode = 310, - FirstJSDocTagNode = 299, - LastJSDocTagNode = 310, + LastBinaryOperator = 72, + FirstNode = 149, + FirstJSDocNode = 289, + LastJSDocNode = 311, + FirstJSDocTagNode = 300, + LastJSDocTagNode = 311, } enum NodeFlags { None = 0, @@ -3160,7 +3162,7 @@ declare namespace ts { reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; - scanJSDocToken(): JsDocSyntaxKind; + scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; getText(): string; setText(text: string | undefined, start?: number, length?: number): void; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d2fd98185b91b..c25e1d733c0c8 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -72,7 +72,7 @@ declare namespace ts { pos: number; end: number; } - type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; + type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { @@ -135,281 +135,283 @@ declare namespace ts { QuestionToken = 56, ColonToken = 57, AtToken = 58, - EqualsToken = 59, - PlusEqualsToken = 60, - MinusEqualsToken = 61, - AsteriskEqualsToken = 62, - AsteriskAsteriskEqualsToken = 63, - SlashEqualsToken = 64, - PercentEqualsToken = 65, - LessThanLessThanEqualsToken = 66, - GreaterThanGreaterThanEqualsToken = 67, - GreaterThanGreaterThanGreaterThanEqualsToken = 68, - AmpersandEqualsToken = 69, - BarEqualsToken = 70, - CaretEqualsToken = 71, - Identifier = 72, - BreakKeyword = 73, - CaseKeyword = 74, - CatchKeyword = 75, - ClassKeyword = 76, - ConstKeyword = 77, - ContinueKeyword = 78, - DebuggerKeyword = 79, - DefaultKeyword = 80, - DeleteKeyword = 81, - DoKeyword = 82, - ElseKeyword = 83, - EnumKeyword = 84, - ExportKeyword = 85, - ExtendsKeyword = 86, - FalseKeyword = 87, - FinallyKeyword = 88, - ForKeyword = 89, - FunctionKeyword = 90, - IfKeyword = 91, - ImportKeyword = 92, - InKeyword = 93, - InstanceOfKeyword = 94, - NewKeyword = 95, - NullKeyword = 96, - ReturnKeyword = 97, - SuperKeyword = 98, - SwitchKeyword = 99, - ThisKeyword = 100, - ThrowKeyword = 101, - TrueKeyword = 102, - TryKeyword = 103, - TypeOfKeyword = 104, - VarKeyword = 105, - VoidKeyword = 106, - WhileKeyword = 107, - WithKeyword = 108, - ImplementsKeyword = 109, - InterfaceKeyword = 110, - LetKeyword = 111, - PackageKeyword = 112, - PrivateKeyword = 113, - ProtectedKeyword = 114, - PublicKeyword = 115, - StaticKeyword = 116, - YieldKeyword = 117, - AbstractKeyword = 118, - AsKeyword = 119, - AnyKeyword = 120, - AsyncKeyword = 121, - AwaitKeyword = 122, - BooleanKeyword = 123, - ConstructorKeyword = 124, - DeclareKeyword = 125, - GetKeyword = 126, - InferKeyword = 127, - IsKeyword = 128, - KeyOfKeyword = 129, - ModuleKeyword = 130, - NamespaceKeyword = 131, - NeverKeyword = 132, - ReadonlyKeyword = 133, - RequireKeyword = 134, - NumberKeyword = 135, - ObjectKeyword = 136, - SetKeyword = 137, - StringKeyword = 138, - SymbolKeyword = 139, - TypeKeyword = 140, - UndefinedKeyword = 141, - UniqueKeyword = 142, - UnknownKeyword = 143, - FromKeyword = 144, - GlobalKeyword = 145, - BigIntKeyword = 146, - OfKeyword = 147, - QualifiedName = 148, - ComputedPropertyName = 149, - TypeParameter = 150, - Parameter = 151, - Decorator = 152, - PropertySignature = 153, - PropertyDeclaration = 154, - MethodSignature = 155, - MethodDeclaration = 156, - Constructor = 157, - GetAccessor = 158, - SetAccessor = 159, - CallSignature = 160, - ConstructSignature = 161, - IndexSignature = 162, - TypePredicate = 163, - TypeReference = 164, - FunctionType = 165, - ConstructorType = 166, - TypeQuery = 167, - TypeLiteral = 168, - ArrayType = 169, - TupleType = 170, - OptionalType = 171, - RestType = 172, - UnionType = 173, - IntersectionType = 174, - ConditionalType = 175, - InferType = 176, - ParenthesizedType = 177, - ThisType = 178, - TypeOperator = 179, - IndexedAccessType = 180, - MappedType = 181, - LiteralType = 182, - ImportType = 183, - ObjectBindingPattern = 184, - ArrayBindingPattern = 185, - BindingElement = 186, - ArrayLiteralExpression = 187, - ObjectLiteralExpression = 188, - PropertyAccessExpression = 189, - ElementAccessExpression = 190, - CallExpression = 191, - NewExpression = 192, - TaggedTemplateExpression = 193, - TypeAssertionExpression = 194, - ParenthesizedExpression = 195, - FunctionExpression = 196, - ArrowFunction = 197, - DeleteExpression = 198, - TypeOfExpression = 199, - VoidExpression = 200, - AwaitExpression = 201, - PrefixUnaryExpression = 202, - PostfixUnaryExpression = 203, - BinaryExpression = 204, - ConditionalExpression = 205, - TemplateExpression = 206, - YieldExpression = 207, - SpreadElement = 208, - ClassExpression = 209, - OmittedExpression = 210, - ExpressionWithTypeArguments = 211, - AsExpression = 212, - NonNullExpression = 213, - MetaProperty = 214, - SyntheticExpression = 215, - TemplateSpan = 216, - SemicolonClassElement = 217, - Block = 218, - VariableStatement = 219, - EmptyStatement = 220, - ExpressionStatement = 221, - IfStatement = 222, - DoStatement = 223, - WhileStatement = 224, - ForStatement = 225, - ForInStatement = 226, - ForOfStatement = 227, - ContinueStatement = 228, - BreakStatement = 229, - ReturnStatement = 230, - WithStatement = 231, - SwitchStatement = 232, - LabeledStatement = 233, - ThrowStatement = 234, - TryStatement = 235, - DebuggerStatement = 236, - VariableDeclaration = 237, - VariableDeclarationList = 238, - FunctionDeclaration = 239, - ClassDeclaration = 240, - InterfaceDeclaration = 241, - TypeAliasDeclaration = 242, - EnumDeclaration = 243, - ModuleDeclaration = 244, - ModuleBlock = 245, - CaseBlock = 246, - NamespaceExportDeclaration = 247, - ImportEqualsDeclaration = 248, - ImportDeclaration = 249, - ImportClause = 250, - NamespaceImport = 251, - NamedImports = 252, - ImportSpecifier = 253, - ExportAssignment = 254, - ExportDeclaration = 255, - NamedExports = 256, - ExportSpecifier = 257, - MissingDeclaration = 258, - ExternalModuleReference = 259, - JsxElement = 260, - JsxSelfClosingElement = 261, - JsxOpeningElement = 262, - JsxClosingElement = 263, - JsxFragment = 264, - JsxOpeningFragment = 265, - JsxClosingFragment = 266, - JsxAttribute = 267, - JsxAttributes = 268, - JsxSpreadAttribute = 269, - JsxExpression = 270, - CaseClause = 271, - DefaultClause = 272, - HeritageClause = 273, - CatchClause = 274, - PropertyAssignment = 275, - ShorthandPropertyAssignment = 276, - SpreadAssignment = 277, - EnumMember = 278, - UnparsedPrologue = 279, - UnparsedPrepend = 280, - UnparsedText = 281, - UnparsedInternalText = 282, - UnparsedSyntheticReference = 283, - SourceFile = 284, - Bundle = 285, - UnparsedSource = 286, - InputFiles = 287, - JSDocTypeExpression = 288, - JSDocAllType = 289, - JSDocUnknownType = 290, - JSDocNullableType = 291, - JSDocNonNullableType = 292, - JSDocOptionalType = 293, - JSDocFunctionType = 294, - JSDocVariadicType = 295, - JSDocComment = 296, - JSDocTypeLiteral = 297, - JSDocSignature = 298, - JSDocTag = 299, - JSDocAugmentsTag = 300, - JSDocClassTag = 301, - JSDocCallbackTag = 302, - JSDocEnumTag = 303, - JSDocParameterTag = 304, - JSDocReturnTag = 305, - JSDocThisTag = 306, - JSDocTypeTag = 307, - JSDocTemplateTag = 308, - JSDocTypedefTag = 309, - JSDocPropertyTag = 310, - SyntaxList = 311, - NotEmittedStatement = 312, - PartiallyEmittedExpression = 313, - CommaListExpression = 314, - MergeDeclarationMarker = 315, - EndOfDeclarationMarker = 316, - Count = 317, - FirstAssignment = 59, - LastAssignment = 71, - FirstCompoundAssignment = 60, - LastCompoundAssignment = 71, - FirstReservedWord = 73, - LastReservedWord = 108, - FirstKeyword = 73, - LastKeyword = 147, - FirstFutureReservedWord = 109, - LastFutureReservedWord = 117, - FirstTypeNode = 163, - LastTypeNode = 183, + /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ + BacktickToken = 59, + EqualsToken = 60, + PlusEqualsToken = 61, + MinusEqualsToken = 62, + AsteriskEqualsToken = 63, + AsteriskAsteriskEqualsToken = 64, + SlashEqualsToken = 65, + PercentEqualsToken = 66, + LessThanLessThanEqualsToken = 67, + GreaterThanGreaterThanEqualsToken = 68, + GreaterThanGreaterThanGreaterThanEqualsToken = 69, + AmpersandEqualsToken = 70, + BarEqualsToken = 71, + CaretEqualsToken = 72, + Identifier = 73, + BreakKeyword = 74, + CaseKeyword = 75, + CatchKeyword = 76, + ClassKeyword = 77, + ConstKeyword = 78, + ContinueKeyword = 79, + DebuggerKeyword = 80, + DefaultKeyword = 81, + DeleteKeyword = 82, + DoKeyword = 83, + ElseKeyword = 84, + EnumKeyword = 85, + ExportKeyword = 86, + ExtendsKeyword = 87, + FalseKeyword = 88, + FinallyKeyword = 89, + ForKeyword = 90, + FunctionKeyword = 91, + IfKeyword = 92, + ImportKeyword = 93, + InKeyword = 94, + InstanceOfKeyword = 95, + NewKeyword = 96, + NullKeyword = 97, + ReturnKeyword = 98, + SuperKeyword = 99, + SwitchKeyword = 100, + ThisKeyword = 101, + ThrowKeyword = 102, + TrueKeyword = 103, + TryKeyword = 104, + TypeOfKeyword = 105, + VarKeyword = 106, + VoidKeyword = 107, + WhileKeyword = 108, + WithKeyword = 109, + ImplementsKeyword = 110, + InterfaceKeyword = 111, + LetKeyword = 112, + PackageKeyword = 113, + PrivateKeyword = 114, + ProtectedKeyword = 115, + PublicKeyword = 116, + StaticKeyword = 117, + YieldKeyword = 118, + AbstractKeyword = 119, + AsKeyword = 120, + AnyKeyword = 121, + AsyncKeyword = 122, + AwaitKeyword = 123, + BooleanKeyword = 124, + ConstructorKeyword = 125, + DeclareKeyword = 126, + GetKeyword = 127, + InferKeyword = 128, + IsKeyword = 129, + KeyOfKeyword = 130, + ModuleKeyword = 131, + NamespaceKeyword = 132, + NeverKeyword = 133, + ReadonlyKeyword = 134, + RequireKeyword = 135, + NumberKeyword = 136, + ObjectKeyword = 137, + SetKeyword = 138, + StringKeyword = 139, + SymbolKeyword = 140, + TypeKeyword = 141, + UndefinedKeyword = 142, + UniqueKeyword = 143, + UnknownKeyword = 144, + FromKeyword = 145, + GlobalKeyword = 146, + BigIntKeyword = 147, + OfKeyword = 148, + QualifiedName = 149, + ComputedPropertyName = 150, + TypeParameter = 151, + Parameter = 152, + Decorator = 153, + PropertySignature = 154, + PropertyDeclaration = 155, + MethodSignature = 156, + MethodDeclaration = 157, + Constructor = 158, + GetAccessor = 159, + SetAccessor = 160, + CallSignature = 161, + ConstructSignature = 162, + IndexSignature = 163, + TypePredicate = 164, + TypeReference = 165, + FunctionType = 166, + ConstructorType = 167, + TypeQuery = 168, + TypeLiteral = 169, + ArrayType = 170, + TupleType = 171, + OptionalType = 172, + RestType = 173, + UnionType = 174, + IntersectionType = 175, + ConditionalType = 176, + InferType = 177, + ParenthesizedType = 178, + ThisType = 179, + TypeOperator = 180, + IndexedAccessType = 181, + MappedType = 182, + LiteralType = 183, + ImportType = 184, + ObjectBindingPattern = 185, + ArrayBindingPattern = 186, + BindingElement = 187, + ArrayLiteralExpression = 188, + ObjectLiteralExpression = 189, + PropertyAccessExpression = 190, + ElementAccessExpression = 191, + CallExpression = 192, + NewExpression = 193, + TaggedTemplateExpression = 194, + TypeAssertionExpression = 195, + ParenthesizedExpression = 196, + FunctionExpression = 197, + ArrowFunction = 198, + DeleteExpression = 199, + TypeOfExpression = 200, + VoidExpression = 201, + AwaitExpression = 202, + PrefixUnaryExpression = 203, + PostfixUnaryExpression = 204, + BinaryExpression = 205, + ConditionalExpression = 206, + TemplateExpression = 207, + YieldExpression = 208, + SpreadElement = 209, + ClassExpression = 210, + OmittedExpression = 211, + ExpressionWithTypeArguments = 212, + AsExpression = 213, + NonNullExpression = 214, + MetaProperty = 215, + SyntheticExpression = 216, + TemplateSpan = 217, + SemicolonClassElement = 218, + Block = 219, + VariableStatement = 220, + EmptyStatement = 221, + ExpressionStatement = 222, + IfStatement = 223, + DoStatement = 224, + WhileStatement = 225, + ForStatement = 226, + ForInStatement = 227, + ForOfStatement = 228, + ContinueStatement = 229, + BreakStatement = 230, + ReturnStatement = 231, + WithStatement = 232, + SwitchStatement = 233, + LabeledStatement = 234, + ThrowStatement = 235, + TryStatement = 236, + DebuggerStatement = 237, + VariableDeclaration = 238, + VariableDeclarationList = 239, + FunctionDeclaration = 240, + ClassDeclaration = 241, + InterfaceDeclaration = 242, + TypeAliasDeclaration = 243, + EnumDeclaration = 244, + ModuleDeclaration = 245, + ModuleBlock = 246, + CaseBlock = 247, + NamespaceExportDeclaration = 248, + ImportEqualsDeclaration = 249, + ImportDeclaration = 250, + ImportClause = 251, + NamespaceImport = 252, + NamedImports = 253, + ImportSpecifier = 254, + ExportAssignment = 255, + ExportDeclaration = 256, + NamedExports = 257, + ExportSpecifier = 258, + MissingDeclaration = 259, + ExternalModuleReference = 260, + JsxElement = 261, + JsxSelfClosingElement = 262, + JsxOpeningElement = 263, + JsxClosingElement = 264, + JsxFragment = 265, + JsxOpeningFragment = 266, + JsxClosingFragment = 267, + JsxAttribute = 268, + JsxAttributes = 269, + JsxSpreadAttribute = 270, + JsxExpression = 271, + CaseClause = 272, + DefaultClause = 273, + HeritageClause = 274, + CatchClause = 275, + PropertyAssignment = 276, + ShorthandPropertyAssignment = 277, + SpreadAssignment = 278, + EnumMember = 279, + UnparsedPrologue = 280, + UnparsedPrepend = 281, + UnparsedText = 282, + UnparsedInternalText = 283, + UnparsedSyntheticReference = 284, + SourceFile = 285, + Bundle = 286, + UnparsedSource = 287, + InputFiles = 288, + JSDocTypeExpression = 289, + JSDocAllType = 290, + JSDocUnknownType = 291, + JSDocNullableType = 292, + JSDocNonNullableType = 293, + JSDocOptionalType = 294, + JSDocFunctionType = 295, + JSDocVariadicType = 296, + JSDocComment = 297, + JSDocTypeLiteral = 298, + JSDocSignature = 299, + JSDocTag = 300, + JSDocAugmentsTag = 301, + JSDocClassTag = 302, + JSDocCallbackTag = 303, + JSDocEnumTag = 304, + JSDocParameterTag = 305, + JSDocReturnTag = 306, + JSDocThisTag = 307, + JSDocTypeTag = 308, + JSDocTemplateTag = 309, + JSDocTypedefTag = 310, + JSDocPropertyTag = 311, + SyntaxList = 312, + NotEmittedStatement = 313, + PartiallyEmittedExpression = 314, + CommaListExpression = 315, + MergeDeclarationMarker = 316, + EndOfDeclarationMarker = 317, + Count = 318, + FirstAssignment = 60, + LastAssignment = 72, + FirstCompoundAssignment = 61, + LastCompoundAssignment = 72, + FirstReservedWord = 74, + LastReservedWord = 109, + FirstKeyword = 74, + LastKeyword = 148, + FirstFutureReservedWord = 110, + LastFutureReservedWord = 118, + FirstTypeNode = 164, + LastTypeNode = 184, FirstPunctuation = 18, - LastPunctuation = 71, + LastPunctuation = 72, FirstToken = 0, - LastToken = 147, + LastToken = 148, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -417,12 +419,12 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 28, - LastBinaryOperator = 71, - FirstNode = 148, - FirstJSDocNode = 288, - LastJSDocNode = 310, - FirstJSDocTagNode = 299, - LastJSDocTagNode = 310, + LastBinaryOperator = 72, + FirstNode = 149, + FirstJSDocNode = 289, + LastJSDocNode = 311, + FirstJSDocTagNode = 300, + LastJSDocTagNode = 311, } enum NodeFlags { None = 0, @@ -3160,7 +3162,7 @@ declare namespace ts { reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; - scanJSDocToken(): JsDocSyntaxKind; + scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; getText(): string; setText(text: string | undefined, start?: number, length?: number): void; diff --git a/tests/baselines/reference/paramTagWrapping.errors.txt b/tests/baselines/reference/paramTagWrapping.errors.txt index 48100f0e7468c..b1564a4f85b8b 100644 --- a/tests/baselines/reference/paramTagWrapping.errors.txt +++ b/tests/baselines/reference/paramTagWrapping.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/jsdoc/bad.js(2,11): error TS1003: Identifier expected. tests/cases/conformance/jsdoc/bad.js(2,11): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. tests/cases/conformance/jsdoc/bad.js(5,4): error TS1003: Identifier expected. tests/cases/conformance/jsdoc/bad.js(5,4): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -tests/cases/conformance/jsdoc/bad.js(6,19): error TS1003: Identifier expected. -tests/cases/conformance/jsdoc/bad.js(6,19): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. +tests/cases/conformance/jsdoc/bad.js(6,20): error TS1003: Identifier expected. +tests/cases/conformance/jsdoc/bad.js(6,20): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. tests/cases/conformance/jsdoc/bad.js(9,14): error TS7006: Parameter 'x' implicitly has an 'any' type. tests/cases/conformance/jsdoc/bad.js(9,17): error TS7006: Parameter 'y' implicitly has an 'any' type. tests/cases/conformance/jsdoc/bad.js(9,20): error TS7006: Parameter 'z' implicitly has an 'any' type. @@ -39,9 +39,9 @@ tests/cases/conformance/jsdoc/bad.js(9,20): error TS7006: Parameter 'z' implicit !!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. * @param {number} * z - + !!! error TS1003: Identifier expected. - + !!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. * Arg z. */ diff --git a/tests/baselines/reference/quickInfoForJSDocCodefence.baseline b/tests/baselines/reference/quickInfoForJSDocCodefence.baseline new file mode 100644 index 0000000000000..a88755fefc947 --- /dev/null +++ b/tests/baselines/reference/quickInfoForJSDocCodefence.baseline @@ -0,0 +1,112 @@ +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoForJSDocCodefence.ts", + "position": 54 + }, + "quickInfo": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 52, + "length": 3 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [], + "tags": [ + { + "name": "example", + "text": "```\n1 + 2\n```" + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoForJSDocCodefence.ts", + "position": 129 + }, + "quickInfo": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 127, + "length": 3 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boo", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [], + "tags": [ + { + "name": "example", + "text": "``\n1 + 2\n`" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForJSDocCodefence.ts b/tests/cases/fourslash/quickInfoForJSDocCodefence.ts new file mode 100644 index 0000000000000..c37d2b896d2cc --- /dev/null +++ b/tests/cases/fourslash/quickInfoForJSDocCodefence.ts @@ -0,0 +1,21 @@ +/// + +/////** +//// * @example +//// * ``` +//// * 1 + 2 +//// * ``` +//// */ +////function fo/*1*/o() { +//// return '2'; +////} +/////** +//// * @example +//// * `` +//// * 1 + 2 +//// * ` +//// */ +////function bo/*2*/o() { +//// return '2'; +////} +verify.baselineQuickInfo();