standard-errors.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _toNodeDescription = require("./to-node-description");
  7. var _default = {
  8. AccessorIsGenerator: ({
  9. kind
  10. }) => `A ${kind}ter cannot be a generator.`,
  11. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  12. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  13. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  14. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  15. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  16. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  17. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  18. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  19. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  20. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  21. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  22. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  23. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  24. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  25. ConstructorIsAsync: "Constructor can't be an async function.",
  26. ConstructorIsGenerator: "Constructor can't be a generator.",
  27. DeclarationMissingInitializer: ({
  28. kind
  29. }) => `Missing initializer in ${kind} declaration.`,
  30. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  31. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  32. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  33. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  34. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  35. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  36. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  37. DeletePrivateField: "Deleting a private field is not allowed.",
  38. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  39. DuplicateConstructor: "Duplicate constructor in the same class.",
  40. DuplicateDefaultExport: "Only one default export allowed per module.",
  41. DuplicateExport: ({
  42. exportName
  43. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  44. DuplicateProto: "Redefinition of __proto__ property.",
  45. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  46. ElementAfterRest: "Rest element must be last element.",
  47. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  48. ExportBindingIsString: ({
  49. localName,
  50. exportName
  51. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  52. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  53. ForInOfLoopInitializer: ({
  54. type
  55. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  56. ForInUsing: "For-in loop may not start with 'using' declaration.",
  57. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  58. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  59. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  60. IllegalBreakContinue: ({
  61. type
  62. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  63. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  64. IllegalReturn: "'return' outside of function.",
  65. ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.",
  66. ImportBindingIsString: ({
  67. importName
  68. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  69. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  70. ImportCallArity: ({
  71. maxArgumentCount
  72. }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
  73. ImportCallNotNewExpression: "Cannot use new with import(...).",
  74. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  75. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  76. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  77. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  78. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  79. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  80. InvalidCodePoint: "Code point out of bounds.",
  81. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  82. InvalidDecimal: "Invalid decimal.",
  83. InvalidDigit: ({
  84. radix
  85. }) => `Expected number in radix ${radix}.`,
  86. InvalidEscapeSequence: "Bad character escape sequence.",
  87. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  88. InvalidEscapedReservedWord: ({
  89. reservedWord
  90. }) => `Escape sequence in keyword ${reservedWord}.`,
  91. InvalidIdentifier: ({
  92. identifierName
  93. }) => `Invalid identifier ${identifierName}.`,
  94. InvalidLhs: ({
  95. ancestor
  96. }) => `Invalid left-hand side in ${(0, _toNodeDescription.default)(ancestor)}.`,
  97. InvalidLhsBinding: ({
  98. ancestor
  99. }) => `Binding invalid left-hand side in ${(0, _toNodeDescription.default)(ancestor)}.`,
  100. InvalidNumber: "Invalid number.",
  101. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  102. InvalidOrUnexpectedToken: ({
  103. unexpected
  104. }) => `Unexpected character '${unexpected}'.`,
  105. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  106. InvalidPrivateFieldResolution: ({
  107. identifierName
  108. }) => `Private name #${identifierName} is not defined.`,
  109. InvalidPropertyBindingPattern: "Binding member expression.",
  110. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  111. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  112. LabelRedeclaration: ({
  113. labelName
  114. }) => `Label '${labelName}' is already declared.`,
  115. LetInLexicalBinding: "'let' is not allowed to be used as a name in 'let' or 'const' declarations.",
  116. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  117. MalformedRegExpFlags: "Invalid regular expression flag.",
  118. MissingClassName: "A class name is required.",
  119. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  120. MissingSemicolon: "Missing semicolon.",
  121. MissingPlugin: ({
  122. missingPlugin
  123. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  124. MissingOneOfPlugins: ({
  125. missingPlugin
  126. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  127. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  128. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  129. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  130. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  131. ModuleAttributesWithDuplicateKeys: ({
  132. key
  133. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  134. ModuleExportNameHasLoneSurrogate: ({
  135. surrogateCharCode
  136. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  137. ModuleExportUndefined: ({
  138. localName
  139. }) => `Export '${localName}' is not defined.`,
  140. MultipleDefaultsInSwitch: "Multiple default clauses.",
  141. NewlineAfterThrow: "Illegal newline after throw.",
  142. NoCatchOrFinally: "Missing catch or finally clause.",
  143. NumberIdentifier: "Identifier directly after number.",
  144. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  145. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  146. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  147. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  148. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  149. ParamDupe: "Argument name clash.",
  150. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  151. PatternHasMethod: "Object pattern can't contain methods.",
  152. PrivateInExpectedIn: ({
  153. identifierName
  154. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  155. PrivateNameRedeclaration: ({
  156. identifierName
  157. }) => `Duplicate private name #${identifierName}.`,
  158. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  159. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  160. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  161. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  162. RestTrailingComma: "Unexpected trailing comma after rest element.",
  163. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  164. SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
  165. StaticPrototype: "Classes may not have static property named prototype.",
  166. SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
  167. SuperPrivateField: "Private fields can't be accessed on super.",
  168. TrailingDecorator: "Decorators must be attached to a class element.",
  169. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  170. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  171. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  172. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  173. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  174. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  175. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  176. UnexpectedKeyword: ({
  177. keyword
  178. }) => `Unexpected keyword '${keyword}'.`,
  179. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  180. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  181. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  182. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  183. UnexpectedPrivateField: "Unexpected private name.",
  184. UnexpectedReservedWord: ({
  185. reservedWord
  186. }) => `Unexpected reserved word '${reservedWord}'.`,
  187. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  188. UnexpectedToken: ({
  189. expected,
  190. unexpected
  191. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  192. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  193. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
  194. UnsupportedBind: "Binding should be performed on object property.",
  195. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  196. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  197. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  198. UnsupportedMetaProperty: ({
  199. target,
  200. onlyValidPropertyName
  201. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  202. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  203. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  204. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  205. UnterminatedComment: "Unterminated comment.",
  206. UnterminatedRegExp: "Unterminated regular expression.",
  207. UnterminatedString: "Unterminated string constant.",
  208. UnterminatedTemplate: "Unterminated template.",
  209. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  210. VarRedeclaration: ({
  211. identifierName
  212. }) => `Identifier '${identifierName}' has already been declared.`,
  213. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  214. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  215. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  216. };
  217. exports.default = _default;
  218. //# sourceMappingURL=standard-errors.js.map