|
| 1 | +export const TypeScriptError = { |
| 2 | + AbstractMethodHasImplementation: ({ methodName }) => |
| 3 | + `Method '${methodName}' cannot have an implementation because it is marked abstract.`, |
| 4 | + AbstractPropertyHasInitializer: ({ |
| 5 | + propertyName |
| 6 | + }) => |
| 7 | + `Property '${propertyName}' cannot have an initializer because it is marked abstract.`, |
| 8 | + AccesorCannotDeclareThisParameter: |
| 9 | + '\'get\' and \'set\' accessors cannot declare \'this\' parameters.', |
| 10 | + AccesorCannotHaveTypeParameters: 'An accessor cannot have type parameters.', |
| 11 | + CannotFindName: ({ name }) => `Cannot find name '${name}'.`, |
| 12 | + ClassMethodHasDeclare: 'Class methods cannot have the \'declare\' modifier.', |
| 13 | + ClassMethodHasReadonly: 'Class methods cannot have the \'readonly\' modifier.', |
| 14 | + ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: |
| 15 | + 'A \'const\' initializer in an ambient context must be a string or numeric literal or literal enum reference.', |
| 16 | + ConstructorHasTypeParameters: |
| 17 | + 'Type parameters cannot appear on a constructor declaration.', |
| 18 | + DeclareAccessor: ({ kind }) => |
| 19 | + `'declare' is not allowed in ${kind}ters.`, |
| 20 | + DeclareClassFieldHasInitializer: |
| 21 | + 'Initializers are not allowed in ambient contexts.', |
| 22 | + DeclareFunctionHasImplementation: |
| 23 | + 'An implementation cannot be declared in ambient contexts.', |
| 24 | + DuplicateAccessibilityModifier: |
| 25 | + // `Accessibility modifier already seen: ${modifier}` would be more helpful. |
| 26 | + // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 27 | + () => |
| 28 | + `Accessibility modifier already seen.`, |
| 29 | + DuplicateModifier: ({ modifier }) => |
| 30 | + `Duplicate modifier: '${modifier}'.`, |
| 31 | + // `token` matches the terminology used by typescript: |
| 32 | + // https://github.com/microsoft/TypeScript/blob/main/src/compiler/types.ts#L2915 |
| 33 | + EmptyHeritageClauseType: ({ token }) => |
| 34 | + `'${token}' list cannot be empty.`, |
| 35 | + EmptyTypeArguments: 'Type argument list cannot be empty.', |
| 36 | + EmptyTypeParameters: 'Type parameter list cannot be empty.', |
| 37 | + ExpectedAmbientAfterExportDeclare: |
| 38 | + '\'export declare\' must be followed by an ambient declaration.', |
| 39 | + ImportAliasHasImportType: 'An import alias can not use \'import type\'.', |
| 40 | + IncompatibleModifiers: ({ |
| 41 | + modifiers |
| 42 | + |
| 43 | + }) => |
| 44 | + `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`, |
| 45 | + IndexSignatureHasAbstract: |
| 46 | + 'Index signatures cannot have the \'abstract\' modifier.', |
| 47 | + IndexSignatureHasAccessibility: ({ |
| 48 | + modifier |
| 49 | + }) => |
| 50 | + `Index signatures cannot have an accessibility modifier ('${modifier}').`, |
| 51 | + IndexSignatureHasDeclare: |
| 52 | + 'Index signatures cannot have the \'declare\' modifier.', |
| 53 | + IndexSignatureHasOverride: |
| 54 | + '\'override\' modifier cannot appear on an index signature.', |
| 55 | + IndexSignatureHasStatic: |
| 56 | + 'Index signatures cannot have the \'static\' modifier.', |
| 57 | + InitializerNotAllowedInAmbientContext: |
| 58 | + 'Initializers are not allowed in ambient contexts.', |
| 59 | + InvalidModifierOnTypeMember: ({ modifier }) => |
| 60 | + `'${modifier}' modifier cannot appear on a type member.`, |
| 61 | + InvalidModifierOnTypeParameter: ({ modifier }) => |
| 62 | + `'${modifier}' modifier cannot appear on a type parameter.`, |
| 63 | + InvalidModifierOnTypeParameterPositions: ({ |
| 64 | + modifier |
| 65 | + }) => |
| 66 | + `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`, |
| 67 | + InvalidModifiersOrder: ({ |
| 68 | + orderedModifiers |
| 69 | + }) => |
| 70 | + `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`, |
| 71 | + InvalidPropertyAccessAfterInstantiationExpression: |
| 72 | + 'Invalid property access after an instantiation expression. ' + |
| 73 | + 'You can either wrap the instantiation expression in parentheses, or delete the type arguments.', |
| 74 | + InvalidTupleMemberLabel: |
| 75 | + 'Tuple members must be labeled with a simple identifier.', |
| 76 | + MissingInterfaceName: |
| 77 | + '\'interface\' declarations must be followed by an identifier.', |
| 78 | + MixedLabeledAndUnlabeledElements: |
| 79 | + 'Tuple members must all have names or all not have names.', |
| 80 | + NonAbstractClassHasAbstractMethod: |
| 81 | + 'Abstract methods can only appear within an abstract class.', |
| 82 | + NonClassMethodPropertyHasAbstractModifer: |
| 83 | + '\'abstract\' modifier can only appear on a class, method, or property declaration.', |
| 84 | + OptionalTypeBeforeRequired: |
| 85 | + 'A required element cannot follow an optional element.', |
| 86 | + OverrideNotInSubClass: |
| 87 | + 'This member cannot have an \'override\' modifier because its containing class does not extend another class.', |
| 88 | + PatternIsOptional: |
| 89 | + 'A binding pattern parameter cannot be optional in an implementation signature.', |
| 90 | + PrivateElementHasAbstract: |
| 91 | + 'Private elements cannot have the \'abstract\' modifier.', |
| 92 | + PrivateElementHasAccessibility: ({ |
| 93 | + modifier |
| 94 | + }) => |
| 95 | + `Private elements cannot have an accessibility modifier ('${modifier}').`, |
| 96 | + ReadonlyForMethodSignature: |
| 97 | + '\'readonly\' modifier can only appear on a property declaration or index signature.', |
| 98 | + ReservedArrowTypeParam: |
| 99 | + 'This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.', |
| 100 | + ReservedTypeAssertion: |
| 101 | + 'This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.', |
| 102 | + SetAccesorCannotHaveOptionalParameter: |
| 103 | + 'A \'set\' accessor cannot have an optional parameter.', |
| 104 | + SetAccesorCannotHaveRestParameter: |
| 105 | + 'A \'set\' accessor cannot have rest parameter.', |
| 106 | + SetAccesorCannotHaveReturnType: |
| 107 | + 'A \'set\' accessor cannot have a return type annotation.', |
| 108 | + SingleTypeParameterWithoutTrailingComma: ({ typeParameterName }) => |
| 109 | + `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`, |
| 110 | + StaticBlockCannotHaveModifier: |
| 111 | + 'Static class blocks cannot have any modifier.', |
| 112 | + TypeAnnotationAfterAssign: |
| 113 | + 'Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.', |
| 114 | + TypeImportCannotSpecifyDefaultAndNamed: |
| 115 | + 'A type-only import can specify a default import or named bindings, but not both.', |
| 116 | + TypeModifierIsUsedInTypeExports: |
| 117 | + 'The \'type\' modifier cannot be used on a named export when \'export type\' is used on its export statement.', |
| 118 | + TypeModifierIsUsedInTypeImports: |
| 119 | + 'The \'type\' modifier cannot be used on a named import when \'import type\' is used on its import statement.', |
| 120 | + UnexpectedParameterModifier: |
| 121 | + 'A parameter property is only allowed in a constructor implementation.', |
| 122 | + UnexpectedReadonly: |
| 123 | + '\'readonly\' type modifier is only permitted on array and tuple literal types.', |
| 124 | + UnexpectedTypeAnnotation: 'Did not expect a type annotation here.', |
| 125 | + UnexpectedTypeCastInParameter: 'Unexpected type cast in parameter position.', |
| 126 | + UnsupportedImportTypeArgument: |
| 127 | + 'Argument in a type import must be a string literal.', |
| 128 | + UnsupportedParameterPropertyKind: |
| 129 | + 'A parameter property may not be declared using a binding pattern.', |
| 130 | + UnsupportedSignatureParameterKind: ({ type }) => |
| 131 | + `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.` |
| 132 | +} |
0 commit comments