From c89f87f66a938db236bd40d1ca51376e38c9b98f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 7 Apr 2023 12:51:47 -0700 Subject: [PATCH] Detect malformed UTF-8 files and refuse to engage further (#53667) --- src/compiler/diagnosticMessages.json | 4 + src/compiler/program.ts | 2 +- src/compiler/scanner.ts | 28 +- src/compiler/types.ts | 6 + .../reference/api/tsserverlibrary.d.ts | 767 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 767 +++++++++--------- .../baselines/reference/corrupted.errors.txt | 7 + tests/baselines/reference/corrupted.js | 4 + tests/baselines/reference/corrupted.symbols | 3 + tests/baselines/reference/corrupted.types | 3 + tests/cases/compiler/corrupted.ts | 1 + 11 files changed, 817 insertions(+), 775 deletions(-) create mode 100644 tests/baselines/reference/corrupted.errors.txt create mode 100644 tests/baselines/reference/corrupted.js create mode 100644 tests/baselines/reference/corrupted.symbols create mode 100644 tests/baselines/reference/corrupted.types create mode 100644 tests/cases/compiler/corrupted.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 41d5450e799..804ffeeff8f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1605,6 +1605,10 @@ "category": "Error", "code": 1489 }, + "File appears to be binary.": { + "category": "Error", + "code": 1490 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6761cf58b9d..a4671bf2098 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -779,7 +779,7 @@ export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagn output += formatColorAndReset(` TS${diagnostic.code}: `, ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); - if (diagnostic.file) { + if (diagnostic.file && diagnostic.code !== Diagnostics.File_appears_to_be_binary.code) { output += host.getNewLine(); output += formatCodeSpan(diagnostic.file, diagnostic.start!, diagnostic.length!, "", getCategoryFormat(diagnostic.category), host); // TODO: GH#18217 } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 741214455f3..32860b744e0 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1782,16 +1782,28 @@ export function createScanner(languageVersion: ScriptTarget, if (pos >= end) { return token = SyntaxKind.EndOfFileToken; } - const ch = codePointAt(text, pos); - // Special handling for shebang - if (ch === CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; + const ch = codePointAt(text, pos); + if (pos === 0) { + // If a file wasn't valid text at all, it will usually be apparent at + // position 0 because UTF-8 decode will fail and produce U+FFFD. + // If that happens, just issue one error and refuse to try to scan further; + // this is likely a binary file that cannot be parsed + if (ch === CharacterCodes.replacementCharacter) { + // Jump to the end of the file and fail. + error(Diagnostics.File_appears_to_be_binary); + pos = end; + return token = SyntaxKind.NonTextFileMarkerTrivia; } - else { - return token = SyntaxKind.ShebangTrivia; + // Special handling for shebang + if (ch === CharacterCodes.hash && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = SyntaxKind.ShebangTrivia; + } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7e14ff22ded..b97d9becc8f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -49,6 +49,9 @@ export const enum SyntaxKind { // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. ConflictMarkerTrivia, + // If a file is actually binary, with any luck, we'll get U+FFFD REPLACEMENT CHARACTER + // in position zero and can just skip what is surely a doomed parse. + NonTextFileMarkerTrivia, // Literals NumericLiteral, BigIntLiteral, @@ -7469,6 +7472,9 @@ export const enum CharacterCodes { mathematicalSpace = 0x205F, ogham = 0x1680, + // Unicode replacement character produced when a byte sequence is invalid + replacementCharacter = 0xFFFD, + _ = 0x5F, $ = 0x24, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 383da6cf665..b5e072fcd1f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4050,395 +4050,396 @@ declare namespace ts { WhitespaceTrivia = 5, ShebangTrivia = 6, ConflictMarkerTrivia = 7, - NumericLiteral = 8, - BigIntLiteral = 9, - StringLiteral = 10, - JsxText = 11, - JsxTextAllWhiteSpaces = 12, - RegularExpressionLiteral = 13, - NoSubstitutionTemplateLiteral = 14, - TemplateHead = 15, - TemplateMiddle = 16, - TemplateTail = 17, - OpenBraceToken = 18, - CloseBraceToken = 19, - OpenParenToken = 20, - CloseParenToken = 21, - OpenBracketToken = 22, - CloseBracketToken = 23, - DotToken = 24, - DotDotDotToken = 25, - SemicolonToken = 26, - CommaToken = 27, - QuestionDotToken = 28, - LessThanToken = 29, - LessThanSlashToken = 30, - GreaterThanToken = 31, - LessThanEqualsToken = 32, - GreaterThanEqualsToken = 33, - EqualsEqualsToken = 34, - ExclamationEqualsToken = 35, - EqualsEqualsEqualsToken = 36, - ExclamationEqualsEqualsToken = 37, - EqualsGreaterThanToken = 38, - PlusToken = 39, - MinusToken = 40, - AsteriskToken = 41, - AsteriskAsteriskToken = 42, - SlashToken = 43, - PercentToken = 44, - PlusPlusToken = 45, - MinusMinusToken = 46, - LessThanLessThanToken = 47, - GreaterThanGreaterThanToken = 48, - GreaterThanGreaterThanGreaterThanToken = 49, - AmpersandToken = 50, - BarToken = 51, - CaretToken = 52, - ExclamationToken = 53, - TildeToken = 54, - AmpersandAmpersandToken = 55, - BarBarToken = 56, - QuestionToken = 57, - ColonToken = 58, - AtToken = 59, - QuestionQuestionToken = 60, + NonTextFileMarkerTrivia = 8, + NumericLiteral = 9, + BigIntLiteral = 10, + StringLiteral = 11, + JsxText = 12, + JsxTextAllWhiteSpaces = 13, + RegularExpressionLiteral = 14, + NoSubstitutionTemplateLiteral = 15, + TemplateHead = 16, + TemplateMiddle = 17, + TemplateTail = 18, + OpenBraceToken = 19, + CloseBraceToken = 20, + OpenParenToken = 21, + CloseParenToken = 22, + OpenBracketToken = 23, + CloseBracketToken = 24, + DotToken = 25, + DotDotDotToken = 26, + SemicolonToken = 27, + CommaToken = 28, + QuestionDotToken = 29, + LessThanToken = 30, + LessThanSlashToken = 31, + GreaterThanToken = 32, + LessThanEqualsToken = 33, + GreaterThanEqualsToken = 34, + EqualsEqualsToken = 35, + ExclamationEqualsToken = 36, + EqualsEqualsEqualsToken = 37, + ExclamationEqualsEqualsToken = 38, + EqualsGreaterThanToken = 39, + PlusToken = 40, + MinusToken = 41, + AsteriskToken = 42, + AsteriskAsteriskToken = 43, + SlashToken = 44, + PercentToken = 45, + PlusPlusToken = 46, + MinusMinusToken = 47, + LessThanLessThanToken = 48, + GreaterThanGreaterThanToken = 49, + GreaterThanGreaterThanGreaterThanToken = 50, + AmpersandToken = 51, + BarToken = 52, + CaretToken = 53, + ExclamationToken = 54, + TildeToken = 55, + AmpersandAmpersandToken = 56, + BarBarToken = 57, + QuestionToken = 58, + ColonToken = 59, + AtToken = 60, + QuestionQuestionToken = 61, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 61, + BacktickToken = 62, /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ - HashToken = 62, - EqualsToken = 63, - PlusEqualsToken = 64, - MinusEqualsToken = 65, - AsteriskEqualsToken = 66, - AsteriskAsteriskEqualsToken = 67, - SlashEqualsToken = 68, - PercentEqualsToken = 69, - LessThanLessThanEqualsToken = 70, - GreaterThanGreaterThanEqualsToken = 71, - GreaterThanGreaterThanGreaterThanEqualsToken = 72, - AmpersandEqualsToken = 73, - BarEqualsToken = 74, - BarBarEqualsToken = 75, - AmpersandAmpersandEqualsToken = 76, - QuestionQuestionEqualsToken = 77, - CaretEqualsToken = 78, - Identifier = 79, - PrivateIdentifier = 80, - BreakKeyword = 82, - CaseKeyword = 83, - CatchKeyword = 84, - ClassKeyword = 85, - ConstKeyword = 86, - ContinueKeyword = 87, - DebuggerKeyword = 88, - DefaultKeyword = 89, - DeleteKeyword = 90, - DoKeyword = 91, - ElseKeyword = 92, - EnumKeyword = 93, - ExportKeyword = 94, - ExtendsKeyword = 95, - FalseKeyword = 96, - FinallyKeyword = 97, - ForKeyword = 98, - FunctionKeyword = 99, - IfKeyword = 100, - ImportKeyword = 101, - InKeyword = 102, - InstanceOfKeyword = 103, - NewKeyword = 104, - NullKeyword = 105, - ReturnKeyword = 106, - SuperKeyword = 107, - SwitchKeyword = 108, - ThisKeyword = 109, - ThrowKeyword = 110, - TrueKeyword = 111, - TryKeyword = 112, - TypeOfKeyword = 113, - VarKeyword = 114, - VoidKeyword = 115, - WhileKeyword = 116, - WithKeyword = 117, - ImplementsKeyword = 118, - InterfaceKeyword = 119, - LetKeyword = 120, - PackageKeyword = 121, - PrivateKeyword = 122, - ProtectedKeyword = 123, - PublicKeyword = 124, - StaticKeyword = 125, - YieldKeyword = 126, - AbstractKeyword = 127, - AccessorKeyword = 128, - AsKeyword = 129, - AssertsKeyword = 130, - AssertKeyword = 131, - AnyKeyword = 132, - AsyncKeyword = 133, - AwaitKeyword = 134, - BooleanKeyword = 135, - ConstructorKeyword = 136, - DeclareKeyword = 137, - GetKeyword = 138, - InferKeyword = 139, - IntrinsicKeyword = 140, - IsKeyword = 141, - KeyOfKeyword = 142, - ModuleKeyword = 143, - NamespaceKeyword = 144, - NeverKeyword = 145, - OutKeyword = 146, - ReadonlyKeyword = 147, - RequireKeyword = 148, - NumberKeyword = 149, - ObjectKeyword = 150, - SatisfiesKeyword = 151, - SetKeyword = 152, - StringKeyword = 153, - SymbolKeyword = 154, - TypeKeyword = 155, - UndefinedKeyword = 156, - UniqueKeyword = 157, - UnknownKeyword = 158, - FromKeyword = 159, - GlobalKeyword = 160, - BigIntKeyword = 161, - OverrideKeyword = 162, - OfKeyword = 163, - QualifiedName = 164, - ComputedPropertyName = 165, - TypeParameter = 166, - Parameter = 167, - Decorator = 168, - PropertySignature = 169, - PropertyDeclaration = 170, - MethodSignature = 171, - MethodDeclaration = 172, - ClassStaticBlockDeclaration = 173, - Constructor = 174, - GetAccessor = 175, - SetAccessor = 176, - CallSignature = 177, - ConstructSignature = 178, - IndexSignature = 179, - TypePredicate = 180, - TypeReference = 181, - FunctionType = 182, - ConstructorType = 183, - TypeQuery = 184, - TypeLiteral = 185, - ArrayType = 186, - TupleType = 187, - OptionalType = 188, - RestType = 189, - UnionType = 190, - IntersectionType = 191, - ConditionalType = 192, - InferType = 193, - ParenthesizedType = 194, - ThisType = 195, - TypeOperator = 196, - IndexedAccessType = 197, - MappedType = 198, - LiteralType = 199, - NamedTupleMember = 200, - TemplateLiteralType = 201, - TemplateLiteralTypeSpan = 202, - ImportType = 203, - ObjectBindingPattern = 204, - ArrayBindingPattern = 205, - BindingElement = 206, - ArrayLiteralExpression = 207, - ObjectLiteralExpression = 208, - PropertyAccessExpression = 209, - ElementAccessExpression = 210, - CallExpression = 211, - NewExpression = 212, - TaggedTemplateExpression = 213, - TypeAssertionExpression = 214, - ParenthesizedExpression = 215, - FunctionExpression = 216, - ArrowFunction = 217, - DeleteExpression = 218, - TypeOfExpression = 219, - VoidExpression = 220, - AwaitExpression = 221, - PrefixUnaryExpression = 222, - PostfixUnaryExpression = 223, - BinaryExpression = 224, - ConditionalExpression = 225, - TemplateExpression = 226, - YieldExpression = 227, - SpreadElement = 228, - ClassExpression = 229, - OmittedExpression = 230, - ExpressionWithTypeArguments = 231, - AsExpression = 232, - NonNullExpression = 233, - MetaProperty = 234, - SyntheticExpression = 235, - SatisfiesExpression = 236, - TemplateSpan = 237, - SemicolonClassElement = 238, - Block = 239, - EmptyStatement = 240, - VariableStatement = 241, - ExpressionStatement = 242, - IfStatement = 243, - DoStatement = 244, - WhileStatement = 245, - ForStatement = 246, - ForInStatement = 247, - ForOfStatement = 248, - ContinueStatement = 249, - BreakStatement = 250, - ReturnStatement = 251, - WithStatement = 252, - SwitchStatement = 253, - LabeledStatement = 254, - ThrowStatement = 255, - TryStatement = 256, - DebuggerStatement = 257, - VariableDeclaration = 258, - VariableDeclarationList = 259, - FunctionDeclaration = 260, - ClassDeclaration = 261, - InterfaceDeclaration = 262, - TypeAliasDeclaration = 263, - EnumDeclaration = 264, - ModuleDeclaration = 265, - ModuleBlock = 266, - CaseBlock = 267, - NamespaceExportDeclaration = 268, - ImportEqualsDeclaration = 269, - ImportDeclaration = 270, - ImportClause = 271, - NamespaceImport = 272, - NamedImports = 273, - ImportSpecifier = 274, - ExportAssignment = 275, - ExportDeclaration = 276, - NamedExports = 277, - NamespaceExport = 278, - ExportSpecifier = 279, - MissingDeclaration = 280, - ExternalModuleReference = 281, - JsxElement = 282, - JsxSelfClosingElement = 283, - JsxOpeningElement = 284, - JsxClosingElement = 285, - JsxFragment = 286, - JsxOpeningFragment = 287, - JsxClosingFragment = 288, - JsxAttribute = 289, - JsxAttributes = 290, - JsxSpreadAttribute = 291, - JsxExpression = 292, - CaseClause = 293, - DefaultClause = 294, - HeritageClause = 295, - CatchClause = 296, - AssertClause = 297, - AssertEntry = 298, - ImportTypeAssertionContainer = 299, - PropertyAssignment = 300, - ShorthandPropertyAssignment = 301, - SpreadAssignment = 302, - EnumMember = 303, - /** @deprecated */ UnparsedPrologue = 304, - /** @deprecated */ UnparsedPrepend = 305, - /** @deprecated */ UnparsedText = 306, - /** @deprecated */ UnparsedInternalText = 307, - /** @deprecated */ UnparsedSyntheticReference = 308, - SourceFile = 309, - Bundle = 310, - /** @deprecated */ UnparsedSource = 311, - /** @deprecated */ InputFiles = 312, - JSDocTypeExpression = 313, - JSDocNameReference = 314, - JSDocMemberName = 315, - JSDocAllType = 316, - JSDocUnknownType = 317, - JSDocNullableType = 318, - JSDocNonNullableType = 319, - JSDocOptionalType = 320, - JSDocFunctionType = 321, - JSDocVariadicType = 322, - JSDocNamepathType = 323, - JSDoc = 324, + HashToken = 63, + EqualsToken = 64, + PlusEqualsToken = 65, + MinusEqualsToken = 66, + AsteriskEqualsToken = 67, + AsteriskAsteriskEqualsToken = 68, + SlashEqualsToken = 69, + PercentEqualsToken = 70, + LessThanLessThanEqualsToken = 71, + GreaterThanGreaterThanEqualsToken = 72, + GreaterThanGreaterThanGreaterThanEqualsToken = 73, + AmpersandEqualsToken = 74, + BarEqualsToken = 75, + BarBarEqualsToken = 76, + AmpersandAmpersandEqualsToken = 77, + QuestionQuestionEqualsToken = 78, + CaretEqualsToken = 79, + Identifier = 80, + PrivateIdentifier = 81, + BreakKeyword = 83, + CaseKeyword = 84, + CatchKeyword = 85, + ClassKeyword = 86, + ConstKeyword = 87, + ContinueKeyword = 88, + DebuggerKeyword = 89, + DefaultKeyword = 90, + DeleteKeyword = 91, + DoKeyword = 92, + ElseKeyword = 93, + EnumKeyword = 94, + ExportKeyword = 95, + ExtendsKeyword = 96, + FalseKeyword = 97, + FinallyKeyword = 98, + ForKeyword = 99, + FunctionKeyword = 100, + IfKeyword = 101, + ImportKeyword = 102, + InKeyword = 103, + InstanceOfKeyword = 104, + NewKeyword = 105, + NullKeyword = 106, + ReturnKeyword = 107, + SuperKeyword = 108, + SwitchKeyword = 109, + ThisKeyword = 110, + ThrowKeyword = 111, + TrueKeyword = 112, + TryKeyword = 113, + TypeOfKeyword = 114, + VarKeyword = 115, + VoidKeyword = 116, + WhileKeyword = 117, + WithKeyword = 118, + ImplementsKeyword = 119, + InterfaceKeyword = 120, + LetKeyword = 121, + PackageKeyword = 122, + PrivateKeyword = 123, + ProtectedKeyword = 124, + PublicKeyword = 125, + StaticKeyword = 126, + YieldKeyword = 127, + AbstractKeyword = 128, + AccessorKeyword = 129, + AsKeyword = 130, + AssertsKeyword = 131, + AssertKeyword = 132, + AnyKeyword = 133, + AsyncKeyword = 134, + AwaitKeyword = 135, + BooleanKeyword = 136, + ConstructorKeyword = 137, + DeclareKeyword = 138, + GetKeyword = 139, + InferKeyword = 140, + IntrinsicKeyword = 141, + IsKeyword = 142, + KeyOfKeyword = 143, + ModuleKeyword = 144, + NamespaceKeyword = 145, + NeverKeyword = 146, + OutKeyword = 147, + ReadonlyKeyword = 148, + RequireKeyword = 149, + NumberKeyword = 150, + ObjectKeyword = 151, + SatisfiesKeyword = 152, + SetKeyword = 153, + StringKeyword = 154, + SymbolKeyword = 155, + TypeKeyword = 156, + UndefinedKeyword = 157, + UniqueKeyword = 158, + UnknownKeyword = 159, + FromKeyword = 160, + GlobalKeyword = 161, + BigIntKeyword = 162, + OverrideKeyword = 163, + OfKeyword = 164, + QualifiedName = 165, + ComputedPropertyName = 166, + TypeParameter = 167, + Parameter = 168, + Decorator = 169, + PropertySignature = 170, + PropertyDeclaration = 171, + MethodSignature = 172, + MethodDeclaration = 173, + ClassStaticBlockDeclaration = 174, + Constructor = 175, + GetAccessor = 176, + SetAccessor = 177, + CallSignature = 178, + ConstructSignature = 179, + IndexSignature = 180, + TypePredicate = 181, + TypeReference = 182, + FunctionType = 183, + ConstructorType = 184, + TypeQuery = 185, + TypeLiteral = 186, + ArrayType = 187, + TupleType = 188, + OptionalType = 189, + RestType = 190, + UnionType = 191, + IntersectionType = 192, + ConditionalType = 193, + InferType = 194, + ParenthesizedType = 195, + ThisType = 196, + TypeOperator = 197, + IndexedAccessType = 198, + MappedType = 199, + LiteralType = 200, + NamedTupleMember = 201, + TemplateLiteralType = 202, + TemplateLiteralTypeSpan = 203, + ImportType = 204, + ObjectBindingPattern = 205, + ArrayBindingPattern = 206, + BindingElement = 207, + ArrayLiteralExpression = 208, + ObjectLiteralExpression = 209, + PropertyAccessExpression = 210, + ElementAccessExpression = 211, + CallExpression = 212, + NewExpression = 213, + TaggedTemplateExpression = 214, + TypeAssertionExpression = 215, + ParenthesizedExpression = 216, + FunctionExpression = 217, + ArrowFunction = 218, + DeleteExpression = 219, + TypeOfExpression = 220, + VoidExpression = 221, + AwaitExpression = 222, + PrefixUnaryExpression = 223, + PostfixUnaryExpression = 224, + BinaryExpression = 225, + ConditionalExpression = 226, + TemplateExpression = 227, + YieldExpression = 228, + SpreadElement = 229, + ClassExpression = 230, + OmittedExpression = 231, + ExpressionWithTypeArguments = 232, + AsExpression = 233, + NonNullExpression = 234, + MetaProperty = 235, + SyntheticExpression = 236, + SatisfiesExpression = 237, + TemplateSpan = 238, + SemicolonClassElement = 239, + Block = 240, + EmptyStatement = 241, + VariableStatement = 242, + ExpressionStatement = 243, + IfStatement = 244, + DoStatement = 245, + WhileStatement = 246, + ForStatement = 247, + ForInStatement = 248, + ForOfStatement = 249, + ContinueStatement = 250, + BreakStatement = 251, + ReturnStatement = 252, + WithStatement = 253, + SwitchStatement = 254, + LabeledStatement = 255, + ThrowStatement = 256, + TryStatement = 257, + DebuggerStatement = 258, + VariableDeclaration = 259, + VariableDeclarationList = 260, + FunctionDeclaration = 261, + ClassDeclaration = 262, + InterfaceDeclaration = 263, + TypeAliasDeclaration = 264, + EnumDeclaration = 265, + ModuleDeclaration = 266, + ModuleBlock = 267, + CaseBlock = 268, + NamespaceExportDeclaration = 269, + ImportEqualsDeclaration = 270, + ImportDeclaration = 271, + ImportClause = 272, + NamespaceImport = 273, + NamedImports = 274, + ImportSpecifier = 275, + ExportAssignment = 276, + ExportDeclaration = 277, + NamedExports = 278, + NamespaceExport = 279, + ExportSpecifier = 280, + MissingDeclaration = 281, + ExternalModuleReference = 282, + JsxElement = 283, + JsxSelfClosingElement = 284, + JsxOpeningElement = 285, + JsxClosingElement = 286, + JsxFragment = 287, + JsxOpeningFragment = 288, + JsxClosingFragment = 289, + JsxAttribute = 290, + JsxAttributes = 291, + JsxSpreadAttribute = 292, + JsxExpression = 293, + CaseClause = 294, + DefaultClause = 295, + HeritageClause = 296, + CatchClause = 297, + AssertClause = 298, + AssertEntry = 299, + ImportTypeAssertionContainer = 300, + PropertyAssignment = 301, + ShorthandPropertyAssignment = 302, + SpreadAssignment = 303, + EnumMember = 304, + /** @deprecated */ UnparsedPrologue = 305, + /** @deprecated */ UnparsedPrepend = 306, + /** @deprecated */ UnparsedText = 307, + /** @deprecated */ UnparsedInternalText = 308, + /** @deprecated */ UnparsedSyntheticReference = 309, + SourceFile = 310, + Bundle = 311, + /** @deprecated */ UnparsedSource = 312, + /** @deprecated */ InputFiles = 313, + JSDocTypeExpression = 314, + JSDocNameReference = 315, + JSDocMemberName = 316, + JSDocAllType = 317, + JSDocUnknownType = 318, + JSDocNullableType = 319, + JSDocNonNullableType = 320, + JSDocOptionalType = 321, + JSDocFunctionType = 322, + JSDocVariadicType = 323, + JSDocNamepathType = 324, + JSDoc = 325, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 324, - JSDocText = 325, - JSDocTypeLiteral = 326, - JSDocSignature = 327, - JSDocLink = 328, - JSDocLinkCode = 329, - JSDocLinkPlain = 330, - JSDocTag = 331, - JSDocAugmentsTag = 332, - JSDocImplementsTag = 333, - JSDocAuthorTag = 334, - JSDocDeprecatedTag = 335, - JSDocClassTag = 336, - JSDocPublicTag = 337, - JSDocPrivateTag = 338, - JSDocProtectedTag = 339, - JSDocReadonlyTag = 340, - JSDocOverrideTag = 341, - JSDocCallbackTag = 342, - JSDocOverloadTag = 343, - JSDocEnumTag = 344, - JSDocParameterTag = 345, - JSDocReturnTag = 346, - JSDocThisTag = 347, - JSDocTypeTag = 348, - JSDocTemplateTag = 349, - JSDocTypedefTag = 350, - JSDocSeeTag = 351, - JSDocPropertyTag = 352, - JSDocThrowsTag = 353, - JSDocSatisfiesTag = 354, - SyntaxList = 355, - NotEmittedStatement = 356, - PartiallyEmittedExpression = 357, - CommaListExpression = 358, - MergeDeclarationMarker = 359, - EndOfDeclarationMarker = 360, - SyntheticReferenceExpression = 361, - Count = 362, - FirstAssignment = 63, - LastAssignment = 78, - FirstCompoundAssignment = 64, - LastCompoundAssignment = 78, - FirstReservedWord = 82, - LastReservedWord = 117, - FirstKeyword = 82, - LastKeyword = 163, - FirstFutureReservedWord = 118, - LastFutureReservedWord = 126, - FirstTypeNode = 180, - LastTypeNode = 203, - FirstPunctuation = 18, - LastPunctuation = 78, + JSDocComment = 325, + JSDocText = 326, + JSDocTypeLiteral = 327, + JSDocSignature = 328, + JSDocLink = 329, + JSDocLinkCode = 330, + JSDocLinkPlain = 331, + JSDocTag = 332, + JSDocAugmentsTag = 333, + JSDocImplementsTag = 334, + JSDocAuthorTag = 335, + JSDocDeprecatedTag = 336, + JSDocClassTag = 337, + JSDocPublicTag = 338, + JSDocPrivateTag = 339, + JSDocProtectedTag = 340, + JSDocReadonlyTag = 341, + JSDocOverrideTag = 342, + JSDocCallbackTag = 343, + JSDocOverloadTag = 344, + JSDocEnumTag = 345, + JSDocParameterTag = 346, + JSDocReturnTag = 347, + JSDocThisTag = 348, + JSDocTypeTag = 349, + JSDocTemplateTag = 350, + JSDocTypedefTag = 351, + JSDocSeeTag = 352, + JSDocPropertyTag = 353, + JSDocThrowsTag = 354, + JSDocSatisfiesTag = 355, + SyntaxList = 356, + NotEmittedStatement = 357, + PartiallyEmittedExpression = 358, + CommaListExpression = 359, + MergeDeclarationMarker = 360, + EndOfDeclarationMarker = 361, + SyntheticReferenceExpression = 362, + Count = 363, + FirstAssignment = 64, + LastAssignment = 79, + FirstCompoundAssignment = 65, + LastCompoundAssignment = 79, + FirstReservedWord = 83, + LastReservedWord = 118, + FirstKeyword = 83, + LastKeyword = 164, + FirstFutureReservedWord = 119, + LastFutureReservedWord = 127, + FirstTypeNode = 181, + LastTypeNode = 204, + FirstPunctuation = 19, + LastPunctuation = 79, FirstToken = 0, - LastToken = 163, + LastToken = 164, FirstTriviaToken = 2, LastTriviaToken = 7, - FirstLiteralToken = 8, - LastLiteralToken = 14, - FirstTemplateToken = 14, - LastTemplateToken = 17, - FirstBinaryOperator = 29, - LastBinaryOperator = 78, - FirstStatement = 241, - LastStatement = 257, - FirstNode = 164, - FirstJSDocNode = 313, - LastJSDocNode = 354, - FirstJSDocTagNode = 331, - LastJSDocTagNode = 354 + FirstLiteralToken = 9, + LastLiteralToken = 15, + FirstTemplateToken = 15, + LastTemplateToken = 18, + FirstBinaryOperator = 30, + LastBinaryOperator = 79, + FirstStatement = 242, + LastStatement = 258, + FirstNode = 165, + FirstJSDocNode = 314, + LastJSDocNode = 355, + FirstJSDocTagNode = 332, + LastJSDocTagNode = 355 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index ee4a8eddd40..9576029a208 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -51,395 +51,396 @@ declare namespace ts { WhitespaceTrivia = 5, ShebangTrivia = 6, ConflictMarkerTrivia = 7, - NumericLiteral = 8, - BigIntLiteral = 9, - StringLiteral = 10, - JsxText = 11, - JsxTextAllWhiteSpaces = 12, - RegularExpressionLiteral = 13, - NoSubstitutionTemplateLiteral = 14, - TemplateHead = 15, - TemplateMiddle = 16, - TemplateTail = 17, - OpenBraceToken = 18, - CloseBraceToken = 19, - OpenParenToken = 20, - CloseParenToken = 21, - OpenBracketToken = 22, - CloseBracketToken = 23, - DotToken = 24, - DotDotDotToken = 25, - SemicolonToken = 26, - CommaToken = 27, - QuestionDotToken = 28, - LessThanToken = 29, - LessThanSlashToken = 30, - GreaterThanToken = 31, - LessThanEqualsToken = 32, - GreaterThanEqualsToken = 33, - EqualsEqualsToken = 34, - ExclamationEqualsToken = 35, - EqualsEqualsEqualsToken = 36, - ExclamationEqualsEqualsToken = 37, - EqualsGreaterThanToken = 38, - PlusToken = 39, - MinusToken = 40, - AsteriskToken = 41, - AsteriskAsteriskToken = 42, - SlashToken = 43, - PercentToken = 44, - PlusPlusToken = 45, - MinusMinusToken = 46, - LessThanLessThanToken = 47, - GreaterThanGreaterThanToken = 48, - GreaterThanGreaterThanGreaterThanToken = 49, - AmpersandToken = 50, - BarToken = 51, - CaretToken = 52, - ExclamationToken = 53, - TildeToken = 54, - AmpersandAmpersandToken = 55, - BarBarToken = 56, - QuestionToken = 57, - ColonToken = 58, - AtToken = 59, - QuestionQuestionToken = 60, + NonTextFileMarkerTrivia = 8, + NumericLiteral = 9, + BigIntLiteral = 10, + StringLiteral = 11, + JsxText = 12, + JsxTextAllWhiteSpaces = 13, + RegularExpressionLiteral = 14, + NoSubstitutionTemplateLiteral = 15, + TemplateHead = 16, + TemplateMiddle = 17, + TemplateTail = 18, + OpenBraceToken = 19, + CloseBraceToken = 20, + OpenParenToken = 21, + CloseParenToken = 22, + OpenBracketToken = 23, + CloseBracketToken = 24, + DotToken = 25, + DotDotDotToken = 26, + SemicolonToken = 27, + CommaToken = 28, + QuestionDotToken = 29, + LessThanToken = 30, + LessThanSlashToken = 31, + GreaterThanToken = 32, + LessThanEqualsToken = 33, + GreaterThanEqualsToken = 34, + EqualsEqualsToken = 35, + ExclamationEqualsToken = 36, + EqualsEqualsEqualsToken = 37, + ExclamationEqualsEqualsToken = 38, + EqualsGreaterThanToken = 39, + PlusToken = 40, + MinusToken = 41, + AsteriskToken = 42, + AsteriskAsteriskToken = 43, + SlashToken = 44, + PercentToken = 45, + PlusPlusToken = 46, + MinusMinusToken = 47, + LessThanLessThanToken = 48, + GreaterThanGreaterThanToken = 49, + GreaterThanGreaterThanGreaterThanToken = 50, + AmpersandToken = 51, + BarToken = 52, + CaretToken = 53, + ExclamationToken = 54, + TildeToken = 55, + AmpersandAmpersandToken = 56, + BarBarToken = 57, + QuestionToken = 58, + ColonToken = 59, + AtToken = 60, + QuestionQuestionToken = 61, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 61, + BacktickToken = 62, /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ - HashToken = 62, - EqualsToken = 63, - PlusEqualsToken = 64, - MinusEqualsToken = 65, - AsteriskEqualsToken = 66, - AsteriskAsteriskEqualsToken = 67, - SlashEqualsToken = 68, - PercentEqualsToken = 69, - LessThanLessThanEqualsToken = 70, - GreaterThanGreaterThanEqualsToken = 71, - GreaterThanGreaterThanGreaterThanEqualsToken = 72, - AmpersandEqualsToken = 73, - BarEqualsToken = 74, - BarBarEqualsToken = 75, - AmpersandAmpersandEqualsToken = 76, - QuestionQuestionEqualsToken = 77, - CaretEqualsToken = 78, - Identifier = 79, - PrivateIdentifier = 80, - BreakKeyword = 82, - CaseKeyword = 83, - CatchKeyword = 84, - ClassKeyword = 85, - ConstKeyword = 86, - ContinueKeyword = 87, - DebuggerKeyword = 88, - DefaultKeyword = 89, - DeleteKeyword = 90, - DoKeyword = 91, - ElseKeyword = 92, - EnumKeyword = 93, - ExportKeyword = 94, - ExtendsKeyword = 95, - FalseKeyword = 96, - FinallyKeyword = 97, - ForKeyword = 98, - FunctionKeyword = 99, - IfKeyword = 100, - ImportKeyword = 101, - InKeyword = 102, - InstanceOfKeyword = 103, - NewKeyword = 104, - NullKeyword = 105, - ReturnKeyword = 106, - SuperKeyword = 107, - SwitchKeyword = 108, - ThisKeyword = 109, - ThrowKeyword = 110, - TrueKeyword = 111, - TryKeyword = 112, - TypeOfKeyword = 113, - VarKeyword = 114, - VoidKeyword = 115, - WhileKeyword = 116, - WithKeyword = 117, - ImplementsKeyword = 118, - InterfaceKeyword = 119, - LetKeyword = 120, - PackageKeyword = 121, - PrivateKeyword = 122, - ProtectedKeyword = 123, - PublicKeyword = 124, - StaticKeyword = 125, - YieldKeyword = 126, - AbstractKeyword = 127, - AccessorKeyword = 128, - AsKeyword = 129, - AssertsKeyword = 130, - AssertKeyword = 131, - AnyKeyword = 132, - AsyncKeyword = 133, - AwaitKeyword = 134, - BooleanKeyword = 135, - ConstructorKeyword = 136, - DeclareKeyword = 137, - GetKeyword = 138, - InferKeyword = 139, - IntrinsicKeyword = 140, - IsKeyword = 141, - KeyOfKeyword = 142, - ModuleKeyword = 143, - NamespaceKeyword = 144, - NeverKeyword = 145, - OutKeyword = 146, - ReadonlyKeyword = 147, - RequireKeyword = 148, - NumberKeyword = 149, - ObjectKeyword = 150, - SatisfiesKeyword = 151, - SetKeyword = 152, - StringKeyword = 153, - SymbolKeyword = 154, - TypeKeyword = 155, - UndefinedKeyword = 156, - UniqueKeyword = 157, - UnknownKeyword = 158, - FromKeyword = 159, - GlobalKeyword = 160, - BigIntKeyword = 161, - OverrideKeyword = 162, - OfKeyword = 163, - QualifiedName = 164, - ComputedPropertyName = 165, - TypeParameter = 166, - Parameter = 167, - Decorator = 168, - PropertySignature = 169, - PropertyDeclaration = 170, - MethodSignature = 171, - MethodDeclaration = 172, - ClassStaticBlockDeclaration = 173, - Constructor = 174, - GetAccessor = 175, - SetAccessor = 176, - CallSignature = 177, - ConstructSignature = 178, - IndexSignature = 179, - TypePredicate = 180, - TypeReference = 181, - FunctionType = 182, - ConstructorType = 183, - TypeQuery = 184, - TypeLiteral = 185, - ArrayType = 186, - TupleType = 187, - OptionalType = 188, - RestType = 189, - UnionType = 190, - IntersectionType = 191, - ConditionalType = 192, - InferType = 193, - ParenthesizedType = 194, - ThisType = 195, - TypeOperator = 196, - IndexedAccessType = 197, - MappedType = 198, - LiteralType = 199, - NamedTupleMember = 200, - TemplateLiteralType = 201, - TemplateLiteralTypeSpan = 202, - ImportType = 203, - ObjectBindingPattern = 204, - ArrayBindingPattern = 205, - BindingElement = 206, - ArrayLiteralExpression = 207, - ObjectLiteralExpression = 208, - PropertyAccessExpression = 209, - ElementAccessExpression = 210, - CallExpression = 211, - NewExpression = 212, - TaggedTemplateExpression = 213, - TypeAssertionExpression = 214, - ParenthesizedExpression = 215, - FunctionExpression = 216, - ArrowFunction = 217, - DeleteExpression = 218, - TypeOfExpression = 219, - VoidExpression = 220, - AwaitExpression = 221, - PrefixUnaryExpression = 222, - PostfixUnaryExpression = 223, - BinaryExpression = 224, - ConditionalExpression = 225, - TemplateExpression = 226, - YieldExpression = 227, - SpreadElement = 228, - ClassExpression = 229, - OmittedExpression = 230, - ExpressionWithTypeArguments = 231, - AsExpression = 232, - NonNullExpression = 233, - MetaProperty = 234, - SyntheticExpression = 235, - SatisfiesExpression = 236, - TemplateSpan = 237, - SemicolonClassElement = 238, - Block = 239, - EmptyStatement = 240, - VariableStatement = 241, - ExpressionStatement = 242, - IfStatement = 243, - DoStatement = 244, - WhileStatement = 245, - ForStatement = 246, - ForInStatement = 247, - ForOfStatement = 248, - ContinueStatement = 249, - BreakStatement = 250, - ReturnStatement = 251, - WithStatement = 252, - SwitchStatement = 253, - LabeledStatement = 254, - ThrowStatement = 255, - TryStatement = 256, - DebuggerStatement = 257, - VariableDeclaration = 258, - VariableDeclarationList = 259, - FunctionDeclaration = 260, - ClassDeclaration = 261, - InterfaceDeclaration = 262, - TypeAliasDeclaration = 263, - EnumDeclaration = 264, - ModuleDeclaration = 265, - ModuleBlock = 266, - CaseBlock = 267, - NamespaceExportDeclaration = 268, - ImportEqualsDeclaration = 269, - ImportDeclaration = 270, - ImportClause = 271, - NamespaceImport = 272, - NamedImports = 273, - ImportSpecifier = 274, - ExportAssignment = 275, - ExportDeclaration = 276, - NamedExports = 277, - NamespaceExport = 278, - ExportSpecifier = 279, - MissingDeclaration = 280, - ExternalModuleReference = 281, - JsxElement = 282, - JsxSelfClosingElement = 283, - JsxOpeningElement = 284, - JsxClosingElement = 285, - JsxFragment = 286, - JsxOpeningFragment = 287, - JsxClosingFragment = 288, - JsxAttribute = 289, - JsxAttributes = 290, - JsxSpreadAttribute = 291, - JsxExpression = 292, - CaseClause = 293, - DefaultClause = 294, - HeritageClause = 295, - CatchClause = 296, - AssertClause = 297, - AssertEntry = 298, - ImportTypeAssertionContainer = 299, - PropertyAssignment = 300, - ShorthandPropertyAssignment = 301, - SpreadAssignment = 302, - EnumMember = 303, - /** @deprecated */ UnparsedPrologue = 304, - /** @deprecated */ UnparsedPrepend = 305, - /** @deprecated */ UnparsedText = 306, - /** @deprecated */ UnparsedInternalText = 307, - /** @deprecated */ UnparsedSyntheticReference = 308, - SourceFile = 309, - Bundle = 310, - /** @deprecated */ UnparsedSource = 311, - /** @deprecated */ InputFiles = 312, - JSDocTypeExpression = 313, - JSDocNameReference = 314, - JSDocMemberName = 315, - JSDocAllType = 316, - JSDocUnknownType = 317, - JSDocNullableType = 318, - JSDocNonNullableType = 319, - JSDocOptionalType = 320, - JSDocFunctionType = 321, - JSDocVariadicType = 322, - JSDocNamepathType = 323, - JSDoc = 324, + HashToken = 63, + EqualsToken = 64, + PlusEqualsToken = 65, + MinusEqualsToken = 66, + AsteriskEqualsToken = 67, + AsteriskAsteriskEqualsToken = 68, + SlashEqualsToken = 69, + PercentEqualsToken = 70, + LessThanLessThanEqualsToken = 71, + GreaterThanGreaterThanEqualsToken = 72, + GreaterThanGreaterThanGreaterThanEqualsToken = 73, + AmpersandEqualsToken = 74, + BarEqualsToken = 75, + BarBarEqualsToken = 76, + AmpersandAmpersandEqualsToken = 77, + QuestionQuestionEqualsToken = 78, + CaretEqualsToken = 79, + Identifier = 80, + PrivateIdentifier = 81, + BreakKeyword = 83, + CaseKeyword = 84, + CatchKeyword = 85, + ClassKeyword = 86, + ConstKeyword = 87, + ContinueKeyword = 88, + DebuggerKeyword = 89, + DefaultKeyword = 90, + DeleteKeyword = 91, + DoKeyword = 92, + ElseKeyword = 93, + EnumKeyword = 94, + ExportKeyword = 95, + ExtendsKeyword = 96, + FalseKeyword = 97, + FinallyKeyword = 98, + ForKeyword = 99, + FunctionKeyword = 100, + IfKeyword = 101, + ImportKeyword = 102, + InKeyword = 103, + InstanceOfKeyword = 104, + NewKeyword = 105, + NullKeyword = 106, + ReturnKeyword = 107, + SuperKeyword = 108, + SwitchKeyword = 109, + ThisKeyword = 110, + ThrowKeyword = 111, + TrueKeyword = 112, + TryKeyword = 113, + TypeOfKeyword = 114, + VarKeyword = 115, + VoidKeyword = 116, + WhileKeyword = 117, + WithKeyword = 118, + ImplementsKeyword = 119, + InterfaceKeyword = 120, + LetKeyword = 121, + PackageKeyword = 122, + PrivateKeyword = 123, + ProtectedKeyword = 124, + PublicKeyword = 125, + StaticKeyword = 126, + YieldKeyword = 127, + AbstractKeyword = 128, + AccessorKeyword = 129, + AsKeyword = 130, + AssertsKeyword = 131, + AssertKeyword = 132, + AnyKeyword = 133, + AsyncKeyword = 134, + AwaitKeyword = 135, + BooleanKeyword = 136, + ConstructorKeyword = 137, + DeclareKeyword = 138, + GetKeyword = 139, + InferKeyword = 140, + IntrinsicKeyword = 141, + IsKeyword = 142, + KeyOfKeyword = 143, + ModuleKeyword = 144, + NamespaceKeyword = 145, + NeverKeyword = 146, + OutKeyword = 147, + ReadonlyKeyword = 148, + RequireKeyword = 149, + NumberKeyword = 150, + ObjectKeyword = 151, + SatisfiesKeyword = 152, + SetKeyword = 153, + StringKeyword = 154, + SymbolKeyword = 155, + TypeKeyword = 156, + UndefinedKeyword = 157, + UniqueKeyword = 158, + UnknownKeyword = 159, + FromKeyword = 160, + GlobalKeyword = 161, + BigIntKeyword = 162, + OverrideKeyword = 163, + OfKeyword = 164, + QualifiedName = 165, + ComputedPropertyName = 166, + TypeParameter = 167, + Parameter = 168, + Decorator = 169, + PropertySignature = 170, + PropertyDeclaration = 171, + MethodSignature = 172, + MethodDeclaration = 173, + ClassStaticBlockDeclaration = 174, + Constructor = 175, + GetAccessor = 176, + SetAccessor = 177, + CallSignature = 178, + ConstructSignature = 179, + IndexSignature = 180, + TypePredicate = 181, + TypeReference = 182, + FunctionType = 183, + ConstructorType = 184, + TypeQuery = 185, + TypeLiteral = 186, + ArrayType = 187, + TupleType = 188, + OptionalType = 189, + RestType = 190, + UnionType = 191, + IntersectionType = 192, + ConditionalType = 193, + InferType = 194, + ParenthesizedType = 195, + ThisType = 196, + TypeOperator = 197, + IndexedAccessType = 198, + MappedType = 199, + LiteralType = 200, + NamedTupleMember = 201, + TemplateLiteralType = 202, + TemplateLiteralTypeSpan = 203, + ImportType = 204, + ObjectBindingPattern = 205, + ArrayBindingPattern = 206, + BindingElement = 207, + ArrayLiteralExpression = 208, + ObjectLiteralExpression = 209, + PropertyAccessExpression = 210, + ElementAccessExpression = 211, + CallExpression = 212, + NewExpression = 213, + TaggedTemplateExpression = 214, + TypeAssertionExpression = 215, + ParenthesizedExpression = 216, + FunctionExpression = 217, + ArrowFunction = 218, + DeleteExpression = 219, + TypeOfExpression = 220, + VoidExpression = 221, + AwaitExpression = 222, + PrefixUnaryExpression = 223, + PostfixUnaryExpression = 224, + BinaryExpression = 225, + ConditionalExpression = 226, + TemplateExpression = 227, + YieldExpression = 228, + SpreadElement = 229, + ClassExpression = 230, + OmittedExpression = 231, + ExpressionWithTypeArguments = 232, + AsExpression = 233, + NonNullExpression = 234, + MetaProperty = 235, + SyntheticExpression = 236, + SatisfiesExpression = 237, + TemplateSpan = 238, + SemicolonClassElement = 239, + Block = 240, + EmptyStatement = 241, + VariableStatement = 242, + ExpressionStatement = 243, + IfStatement = 244, + DoStatement = 245, + WhileStatement = 246, + ForStatement = 247, + ForInStatement = 248, + ForOfStatement = 249, + ContinueStatement = 250, + BreakStatement = 251, + ReturnStatement = 252, + WithStatement = 253, + SwitchStatement = 254, + LabeledStatement = 255, + ThrowStatement = 256, + TryStatement = 257, + DebuggerStatement = 258, + VariableDeclaration = 259, + VariableDeclarationList = 260, + FunctionDeclaration = 261, + ClassDeclaration = 262, + InterfaceDeclaration = 263, + TypeAliasDeclaration = 264, + EnumDeclaration = 265, + ModuleDeclaration = 266, + ModuleBlock = 267, + CaseBlock = 268, + NamespaceExportDeclaration = 269, + ImportEqualsDeclaration = 270, + ImportDeclaration = 271, + ImportClause = 272, + NamespaceImport = 273, + NamedImports = 274, + ImportSpecifier = 275, + ExportAssignment = 276, + ExportDeclaration = 277, + NamedExports = 278, + NamespaceExport = 279, + ExportSpecifier = 280, + MissingDeclaration = 281, + ExternalModuleReference = 282, + JsxElement = 283, + JsxSelfClosingElement = 284, + JsxOpeningElement = 285, + JsxClosingElement = 286, + JsxFragment = 287, + JsxOpeningFragment = 288, + JsxClosingFragment = 289, + JsxAttribute = 290, + JsxAttributes = 291, + JsxSpreadAttribute = 292, + JsxExpression = 293, + CaseClause = 294, + DefaultClause = 295, + HeritageClause = 296, + CatchClause = 297, + AssertClause = 298, + AssertEntry = 299, + ImportTypeAssertionContainer = 300, + PropertyAssignment = 301, + ShorthandPropertyAssignment = 302, + SpreadAssignment = 303, + EnumMember = 304, + /** @deprecated */ UnparsedPrologue = 305, + /** @deprecated */ UnparsedPrepend = 306, + /** @deprecated */ UnparsedText = 307, + /** @deprecated */ UnparsedInternalText = 308, + /** @deprecated */ UnparsedSyntheticReference = 309, + SourceFile = 310, + Bundle = 311, + /** @deprecated */ UnparsedSource = 312, + /** @deprecated */ InputFiles = 313, + JSDocTypeExpression = 314, + JSDocNameReference = 315, + JSDocMemberName = 316, + JSDocAllType = 317, + JSDocUnknownType = 318, + JSDocNullableType = 319, + JSDocNonNullableType = 320, + JSDocOptionalType = 321, + JSDocFunctionType = 322, + JSDocVariadicType = 323, + JSDocNamepathType = 324, + JSDoc = 325, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 324, - JSDocText = 325, - JSDocTypeLiteral = 326, - JSDocSignature = 327, - JSDocLink = 328, - JSDocLinkCode = 329, - JSDocLinkPlain = 330, - JSDocTag = 331, - JSDocAugmentsTag = 332, - JSDocImplementsTag = 333, - JSDocAuthorTag = 334, - JSDocDeprecatedTag = 335, - JSDocClassTag = 336, - JSDocPublicTag = 337, - JSDocPrivateTag = 338, - JSDocProtectedTag = 339, - JSDocReadonlyTag = 340, - JSDocOverrideTag = 341, - JSDocCallbackTag = 342, - JSDocOverloadTag = 343, - JSDocEnumTag = 344, - JSDocParameterTag = 345, - JSDocReturnTag = 346, - JSDocThisTag = 347, - JSDocTypeTag = 348, - JSDocTemplateTag = 349, - JSDocTypedefTag = 350, - JSDocSeeTag = 351, - JSDocPropertyTag = 352, - JSDocThrowsTag = 353, - JSDocSatisfiesTag = 354, - SyntaxList = 355, - NotEmittedStatement = 356, - PartiallyEmittedExpression = 357, - CommaListExpression = 358, - MergeDeclarationMarker = 359, - EndOfDeclarationMarker = 360, - SyntheticReferenceExpression = 361, - Count = 362, - FirstAssignment = 63, - LastAssignment = 78, - FirstCompoundAssignment = 64, - LastCompoundAssignment = 78, - FirstReservedWord = 82, - LastReservedWord = 117, - FirstKeyword = 82, - LastKeyword = 163, - FirstFutureReservedWord = 118, - LastFutureReservedWord = 126, - FirstTypeNode = 180, - LastTypeNode = 203, - FirstPunctuation = 18, - LastPunctuation = 78, + JSDocComment = 325, + JSDocText = 326, + JSDocTypeLiteral = 327, + JSDocSignature = 328, + JSDocLink = 329, + JSDocLinkCode = 330, + JSDocLinkPlain = 331, + JSDocTag = 332, + JSDocAugmentsTag = 333, + JSDocImplementsTag = 334, + JSDocAuthorTag = 335, + JSDocDeprecatedTag = 336, + JSDocClassTag = 337, + JSDocPublicTag = 338, + JSDocPrivateTag = 339, + JSDocProtectedTag = 340, + JSDocReadonlyTag = 341, + JSDocOverrideTag = 342, + JSDocCallbackTag = 343, + JSDocOverloadTag = 344, + JSDocEnumTag = 345, + JSDocParameterTag = 346, + JSDocReturnTag = 347, + JSDocThisTag = 348, + JSDocTypeTag = 349, + JSDocTemplateTag = 350, + JSDocTypedefTag = 351, + JSDocSeeTag = 352, + JSDocPropertyTag = 353, + JSDocThrowsTag = 354, + JSDocSatisfiesTag = 355, + SyntaxList = 356, + NotEmittedStatement = 357, + PartiallyEmittedExpression = 358, + CommaListExpression = 359, + MergeDeclarationMarker = 360, + EndOfDeclarationMarker = 361, + SyntheticReferenceExpression = 362, + Count = 363, + FirstAssignment = 64, + LastAssignment = 79, + FirstCompoundAssignment = 65, + LastCompoundAssignment = 79, + FirstReservedWord = 83, + LastReservedWord = 118, + FirstKeyword = 83, + LastKeyword = 164, + FirstFutureReservedWord = 119, + LastFutureReservedWord = 127, + FirstTypeNode = 181, + LastTypeNode = 204, + FirstPunctuation = 19, + LastPunctuation = 79, FirstToken = 0, - LastToken = 163, + LastToken = 164, FirstTriviaToken = 2, LastTriviaToken = 7, - FirstLiteralToken = 8, - LastLiteralToken = 14, - FirstTemplateToken = 14, - LastTemplateToken = 17, - FirstBinaryOperator = 29, - LastBinaryOperator = 78, - FirstStatement = 241, - LastStatement = 257, - FirstNode = 164, - FirstJSDocNode = 313, - LastJSDocNode = 354, - FirstJSDocTagNode = 331, - LastJSDocTagNode = 354 + FirstLiteralToken = 9, + LastLiteralToken = 15, + FirstTemplateToken = 15, + LastTemplateToken = 18, + FirstBinaryOperator = 30, + LastBinaryOperator = 79, + FirstStatement = 242, + LastStatement = 258, + FirstNode = 165, + FirstJSDocNode = 314, + LastJSDocNode = 355, + FirstJSDocTagNode = 332, + LastJSDocTagNode = 355 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; diff --git a/tests/baselines/reference/corrupted.errors.txt b/tests/baselines/reference/corrupted.errors.txt new file mode 100644 index 00000000000..d5468e0a8fa --- /dev/null +++ b/tests/baselines/reference/corrupted.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/corrupted.ts(1,1): error TS1490: File appears to be binary. + + +==== tests/cases/compiler/corrupted.ts (1 errors) ==== + ��� + +!!! error TS1490: File appears to be binary. \ No newline at end of file diff --git a/tests/baselines/reference/corrupted.js b/tests/baselines/reference/corrupted.js new file mode 100644 index 00000000000..72d9542ac04 --- /dev/null +++ b/tests/baselines/reference/corrupted.js @@ -0,0 +1,4 @@ +//// [corrupted.ts] +��� + +//// [corrupted.js] diff --git a/tests/baselines/reference/corrupted.symbols b/tests/baselines/reference/corrupted.symbols new file mode 100644 index 00000000000..7ba94fffc81 --- /dev/null +++ b/tests/baselines/reference/corrupted.symbols @@ -0,0 +1,3 @@ +=== tests/cases/compiler/corrupted.ts === + +��� diff --git a/tests/baselines/reference/corrupted.types b/tests/baselines/reference/corrupted.types new file mode 100644 index 00000000000..7ba94fffc81 --- /dev/null +++ b/tests/baselines/reference/corrupted.types @@ -0,0 +1,3 @@ +=== tests/cases/compiler/corrupted.ts === + +��� diff --git a/tests/cases/compiler/corrupted.ts b/tests/cases/compiler/corrupted.ts new file mode 100644 index 00000000000..5e2f16e9b92 --- /dev/null +++ b/tests/cases/compiler/corrupted.ts @@ -0,0 +1 @@ +ƼÁ \ No newline at end of file