--noImplicitOverride (#39669)

* wip: add types

* wip

* Add cases

* Add some case

* Add more check

* accept baseline

* add abstract abd declare method

* add override in declaration

* accept baseline

* add property override

* Fix decalre modifier

* update baseline

* Add more cases

* make lint happy

* make lint happy

* Update description

* Add codefix

* simplify code

* accept baseline

* Update desc

* Accept baseline

* Add override completions

* filter out implements field in override context

* fix tests

* Add parameter property check

* Accept baseline

* acept baseline

* Add parameter property to declaration code action

* Add quickfix for override parameter property

* fix code style

* Add override with interface tests

* Add more cases about modifier position

* rename flag

* rename flags

* Added tests.

* Accepted baselines.

* Always issue errors for unnecessary 'override' modifiers.

* Accepted baselines.

* Override perf (#4)

* try cache check result

* pre check for override

* Do not issue error if implement abstract

* Add abstract-spec check

* Avoid override dead lock

* Add more case

* Add codefix for new error

* Fix error message

* Add jsdoc override tag (#6)

* Override jsdoc tag (#7)

* accept baseline

* Disallow codefix in js

* update baseline

* Omit override in d.ts

* Add more case in js

* Accept baseline

* fix override js test

* fix crlf

* Revert merge conflict changes

* Accept baseline

* Avoid space

* Fix CR issues

* Accept baseline

* Fix typo and add more check

* Fix error name

Co-authored-by: Daniel Rosenwasser <Daniel.Rosenwasser@microsoft.com>
This commit is contained in:
Wenlu WangandDaniel Rosenwasser authored and GitHub committed 2021-03-26 16:29:22 -07:00
1 parent 41dc625b0a
commit 2f0c8b2bea
131 files changed
+5281 -426

No files matched your search

+88 -2
View File
@@ -36664,7 +36664,8 @@ namespace ts {
checkClassForDuplicateDeclarations(node);
// Only check for reserved static identifiers on non-ambient context.
if (!(node.flags & NodeFlags.Ambient)) {
const nodeInAmbientContext = !!(node.flags & NodeFlags.Ambient);
if (!nodeInAmbientContext) {
checkClassForStaticPropertyNameConflicts(node);
}
@@ -36728,6 +36729,8 @@ namespace ts {
}
}
checkMembersForMissingOverrideModifier(node, type, typeWithThis);
const implementedTypeNodes = getEffectiveImplementsTypeNodes(node);
if (implementedTypeNodes) {
for (const typeRefNode of implementedTypeNodes) {
@@ -36763,6 +36766,60 @@ namespace ts {
}
}
function checkMembersForMissingOverrideModifier(node: ClassLikeDeclaration, type: InterfaceType, typeWithThis: Type) {
const nodeInAmbientContext = !!(node.flags & NodeFlags.Ambient);
const baseTypeNode = getEffectiveBaseTypeNode(node);
const baseTypes = baseTypeNode && getBaseTypes(type);
const baseWithThis = baseTypes?.length ? getTypeWithThisArgument(first(baseTypes), type.thisType) : undefined;
for (const member of node.members) {
if (isConstructorDeclaration(member)) {
forEach(member.parameters, param => {
if (isParameterPropertyDeclaration(param, member)) {
checkClassMember(param, /*memberIsParameterProperty*/ true);
}
});
}
checkClassMember(member);
}
function checkClassMember(member: ClassElement | ParameterPropertyDeclaration, memberIsParameterProperty?: boolean) {
const hasOverride = hasOverrideModifier(member);
if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) {
const declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
if (!declaredProp) {
return;
}
const baseClassName = typeToString(baseWithThis);
const prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
const baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
if (prop && !baseProp && hasOverride) {
error(member, Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
}
else if (prop && baseProp?.valueDeclaration && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
const baseHasAbstract = hasAbstractModifier(baseProp.valueDeclaration);
if (hasOverride) {
return;
}
if (!baseHasAbstract) {
const diag = memberIsParameterProperty ?
Diagnostics.This_parameter_property_must_be_rewritten_as_a_property_declaration_with_an_override_modifier_because_it_overrides_a_member_in_base_class_0 :
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
error(member, diag, baseClassName);
}
else if (hasAbstractModifier(member) && baseHasAbstract) {
error(member, Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
}
}
}
else if (hasOverride) {
const className = typeToString(type);
error(member, Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
}
}
}
function issueMemberSpecificError(node: ClassLikeDeclaration, typeWithThis: Type, baseWithThis: Type, broadDiag: DiagnosticMessage) {
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
let issuedMemberError = false;
@@ -40137,7 +40194,7 @@ namespace ts {
return quickResult;
}
let lastStatic: Node | undefined, lastDeclare: Node | undefined, lastAsync: Node | undefined, lastReadonly: Node | undefined;
let lastStatic: Node | undefined, lastDeclare: Node | undefined, lastAsync: Node | undefined, lastReadonly: Node | undefined, lastOverride: Node | undefined;
let flags = ModifierFlags.None;
for (const modifier of node.modifiers!) {
if (modifier.kind !== SyntaxKind.ReadonlyKeyword) {
@@ -40154,6 +40211,23 @@ namespace ts {
return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(SyntaxKind.ConstKeyword));
}
break;
case SyntaxKind.OverrideKeyword:
if (flags & ModifierFlags.Override) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "override");
}
else if (flags & ModifierFlags.Ambient) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare");
}
else if (flags & ModifierFlags.Static) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "override");
}
if (node.kind === SyntaxKind.Parameter) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "override");
}
flags |= ModifierFlags.Override;
lastOverride = modifier;
break;
case SyntaxKind.PublicKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.PrivateKeyword:
@@ -40162,6 +40236,9 @@ namespace ts {
if (flags & ModifierFlags.AccessibilityModifier) {
return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen);
}
else if (compilerOptions.noImplicitOverride && flags & ModifierFlags.Override) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "override");
}
else if (flags & ModifierFlags.Static) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
}
@@ -40195,6 +40272,9 @@ namespace ts {
else if (flags & ModifierFlags.Readonly) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
}
else if (compilerOptions.noImplicitOverride && flags & ModifierFlags.Override) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "override");
}
else if (flags & ModifierFlags.Async) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
}
@@ -40259,6 +40339,9 @@ namespace ts {
else if (flags & ModifierFlags.Async) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
}
else if (compilerOptions.noImplicitOverride && flags & ModifierFlags.Override) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override");
}
else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare");
}
@@ -40333,6 +40416,9 @@ namespace ts {
if (flags & ModifierFlags.Abstract) {
return grammarErrorOnNode(lastStatic!, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
}
if (compilerOptions.noImplicitOverride && flags & ModifierFlags.Override) {
return grammarErrorOnNode(lastOverride!, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
}
else if (flags & ModifierFlags.Async) {
return grammarErrorOnNode(lastAsync!, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
}
+8
View File
@@ -675,6 +675,14 @@ namespace ts {
category: Diagnostics.Additional_Checks,
description: Diagnostics.Include_undefined_in_index_signature_results
},
{
name: "noImplicitOverride",
type: "boolean",
affectsSemanticDiagnostics: true,
showInSimplifiedHelpView: false,
category: Diagnostics.Additional_Checks,
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier
},
{
name: "noPropertyAccessFromIndexSignature",
type: "boolean",
+44 -4
View File
@@ -3685,6 +3685,26 @@
"category": "Error",
"code": 4111
},
"This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class.": {
"category": "Error",
"code": 4112
},
"This member cannot have an 'override' modifier because it is not declared in the base class '{0}'.": {
"category": "Error",
"code": 4113
},
"This member must have an 'override' modifier because it overrides a member in the base class '{0}'.": {
"category": "Error",
"code": 4114
},
"This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class '{0}'.": {
"category": "Error",
"code": 4115
},
"This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'.": {
"category": "Error",
"code": 4116
},
"The current host does not support the '{0}' option.": {
"category": "Error",
@@ -5018,15 +5038,19 @@
"category": "Message",
"code": 6505
},
"Require undeclared properties from index signatures to use element accesses.": {
"category": "Error",
"code": 6803
},
"Include 'undefined' in index signature results": {
"category": "Message",
"code": 6800
},
"Ensure overriding members in derived classes are marked with an 'override' modifier.": {
"category": "Message",
"code": 6801
},
"Require undeclared properties from index signatures to use element accesses.": {
"category": "Message",
"code": 6802
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
@@ -6301,6 +6325,22 @@
"category": "Message",
"code": 95159
},
"Add 'override' modifier": {
"category": "Message",
"code": 95160
},
"Remove 'override' modifier": {
"category": "Message",
"code": 95161
},
"Add all missing 'override' modifiers": {
"category": "Message",
"code": 95162
},
"Remove all unnecessary 'override' modifiers": {
"category": "Message",
"code": 95163
},
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
"category": "Error",
+4
View File
@@ -368,6 +368,8 @@ namespace ts {
get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction<JSDocProtectedTag>(SyntaxKind.JSDocProtectedTag); },
get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction<JSDocReadonlyTag>(SyntaxKind.JSDocReadonlyTag); },
get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction<JSDocReadonlyTag>(SyntaxKind.JSDocReadonlyTag); },
get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction<JSDocOverrideTag>(SyntaxKind.JSDocOverrideTag); },
get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction<JSDocOverrideTag>(SyntaxKind.JSDocOverrideTag); },
get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction<JSDocDeprecatedTag>(SyntaxKind.JSDocDeprecatedTag); },
get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction<JSDocDeprecatedTag>(SyntaxKind.JSDocDeprecatedTag); },
createJSDocUnknownTag,
@@ -1041,6 +1043,7 @@ namespace ts {
if (flags & ModifierFlags.Static) { result.push(createModifier(SyntaxKind.StaticKeyword)); }
if (flags & ModifierFlags.Readonly) { result.push(createModifier(SyntaxKind.ReadonlyKeyword)); }
if (flags & ModifierFlags.Async) { result.push(createModifier(SyntaxKind.AsyncKeyword)); }
if (flags & ModifierFlags.Override) { result.push(createModifier(SyntaxKind.OverrideKeyword)); }
return result;
}
@@ -5934,6 +5937,7 @@ namespace ts {
case SyntaxKind.JSDocPrivateTag: return "private";
case SyntaxKind.JSDocProtectedTag: return "protected";
case SyntaxKind.JSDocReadonlyTag: return "readonly";
case SyntaxKind.JSDocOverrideTag: return "override";
case SyntaxKind.JSDocTemplateTag: return "template";
case SyntaxKind.JSDocTypedefTag: return "typedef";
case SyntaxKind.JSDocParameterTag: return "param";
+4
View File
@@ -852,6 +852,10 @@ namespace ts {
return node.kind === SyntaxKind.JSDocReadonlyTag;
}
export function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag {
return node.kind === SyntaxKind.JSDocOverrideTag;
}
export function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag {
return node.kind === SyntaxKind.JSDocDeprecatedTag;
}
+3
View File
@@ -7542,6 +7542,9 @@ namespace ts {
case "readonly":
tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText);
break;
case "override":
tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText);
break;
case "deprecated":
hasDeprecatedTag = true;
tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText);
+1
View File
@@ -2148,6 +2148,7 @@ namespace ts {
case SyntaxKind.ReadonlyKeyword:
case SyntaxKind.DeclareKeyword:
case SyntaxKind.AbstractKeyword:
case SyntaxKind.OverrideKeyword:
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, tokenToString(modifier.kind)));
break;
+1
View File
@@ -127,6 +127,7 @@ namespace ts {
private: SyntaxKind.PrivateKeyword,
protected: SyntaxKind.ProtectedKeyword,
public: SyntaxKind.PublicKeyword,
override: SyntaxKind.OverrideKeyword,
readonly: SyntaxKind.ReadonlyKeyword,
require: SyntaxKind.RequireKeyword,
global: SyntaxKind.GlobalKeyword,
+1 -1
View File
@@ -1540,7 +1540,7 @@ namespace ts {
}
function ensureModifierFlags(node: Node): ModifierFlags {
let mask = ModifierFlags.All ^ (ModifierFlags.Public | ModifierFlags.Async); // No async modifiers in declaration files
let mask = ModifierFlags.All ^ (ModifierFlags.Public | ModifierFlags.Async | ModifierFlags.Override); // No async and override modifiers in declaration files
let additions = (needsDeclare && !isAlwaysType(node)) ? ModifierFlags.Ambient : ModifierFlags.None;
const parentIsFile = node.parent.kind === SyntaxKind.SourceFile;
if (!parentIsFile || (isBundledEmit && parentIsFile && isExternalModule(node.parent as SourceFile))) {
+16 -2
View File
@@ -187,6 +187,7 @@ namespace ts {
FromKeyword,
GlobalKeyword,
BigIntKeyword,
OverrideKeyword,
OfKeyword, // LastKeyword and LastToken and LastContextualKeyword
// Parse tree nodes
@@ -384,6 +385,7 @@ namespace ts {
JSDocPrivateTag,
JSDocProtectedTag,
JSDocReadonlyTag,
JSDocOverrideTag,
JSDocCallbackTag,
JSDocEnumTag,
JSDocParameterTag,
@@ -586,6 +588,7 @@ namespace ts {
| SyntaxKind.ProtectedKeyword
| SyntaxKind.PublicKeyword
| SyntaxKind.ReadonlyKeyword
| SyntaxKind.OverrideKeyword
| SyntaxKind.RequireKeyword
| SyntaxKind.ReturnKeyword
| SyntaxKind.SetKeyword
@@ -621,6 +624,7 @@ namespace ts {
| SyntaxKind.ProtectedKeyword
| SyntaxKind.PublicKeyword
| SyntaxKind.ReadonlyKeyword
| SyntaxKind.OverrideKeyword
| SyntaxKind.StaticKeyword
;
@@ -797,6 +801,7 @@ namespace ts {
HasComputedJSDocModifiers = 1 << 12, // Indicates the computed modifier flags include modifiers from JSDoc.
Deprecated = 1 << 13, // Deprecated tag.
Override = 1 << 14, // Override method.
HasComputedFlags = 1 << 29, // Modifier flags have been computed
AccessibilityModifier = Public | Private | Protected,
@@ -804,9 +809,9 @@ namespace ts {
ParameterPropertyModifier = AccessibilityModifier | Readonly,
NonPublicAccessibilityModifier = Private | Protected,
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const,
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override,
ExportDefault = Export | Default,
All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated
All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated | Override
}
export const enum JsxFlags {
@@ -1027,6 +1032,7 @@ namespace ts {
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
/** @deprecated Use `ReadonlyKeyword` instead. */
@@ -1042,6 +1048,7 @@ namespace ts {
| PrivateKeyword
| ProtectedKeyword
| PublicKeyword
| OverrideKeyword
| ReadonlyKeyword
| StaticKeyword
;
@@ -3221,6 +3228,10 @@ namespace ts {
readonly kind: SyntaxKind.JSDocReadonlyTag;
}
export interface JSDocOverrideTag extends JSDocTag {
readonly kind: SyntaxKind.JSDocOverrideTag;
}
export interface JSDocEnumTag extends JSDocTag, Declaration {
readonly kind: SyntaxKind.JSDocEnumTag;
readonly parent: JSDoc;
@@ -5927,6 +5938,7 @@ namespace ts {
/*@internal*/ pathsBasePath?: string;
/*@internal*/ plugins?: PluginImport[];
preserveConstEnums?: boolean;
noImplicitOverride?: boolean;
preserveSymlinks?: boolean;
/* @internal */ preserveWatchOutput?: boolean;
project?: string;
@@ -7245,6 +7257,8 @@ namespace ts {
updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocText | JSDocLink> | undefined): JSDocUnknownTag;
createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocDeprecatedTag;
updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocDeprecatedTag;
createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocOverrideTag;
updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocOverrideTag;
createJSDocText(text: string): JSDocText;
updateJSDocText(node: JSDocText, text: string): JSDocText;
createJSDocComment(comment?: string | NodeArray<JSDocText | JSDocLink> | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc;
+18
View File
@@ -4668,6 +4668,18 @@ namespace ts {
return hasSyntacticModifier(node, ModifierFlags.Static);
}
export function hasOverrideModifier(node: Node): boolean {
return hasEffectiveModifier(node, ModifierFlags.Override);
}
export function hasAbstractModifier(node: Node): boolean {
return hasSyntacticModifier(node, ModifierFlags.Abstract);
}
export function hasAmbientModifier(node: Node): boolean {
return hasSyntacticModifier(node, ModifierFlags.Ambient);
}
export function hasEffectiveReadonlyModifier(node: Node): boolean {
return hasEffectiveModifier(node, ModifierFlags.Readonly);
}
@@ -4726,6 +4738,7 @@ namespace ts {
if (getJSDocPrivateTagNoCache(node)) flags |= ModifierFlags.Private;
if (getJSDocProtectedTagNoCache(node)) flags |= ModifierFlags.Protected;
if (getJSDocReadonlyTagNoCache(node)) flags |= ModifierFlags.Readonly;
if (getJSDocOverrideTagNoCache(node)) flags |= ModifierFlags.Override;
}
if (getJSDocDeprecatedTagNoCache(node)) flags |= ModifierFlags.Deprecated;
}
@@ -4778,10 +4791,15 @@ namespace ts {
case SyntaxKind.DefaultKeyword: return ModifierFlags.Default;
case SyntaxKind.AsyncKeyword: return ModifierFlags.Async;
case SyntaxKind.ReadonlyKeyword: return ModifierFlags.Readonly;
case SyntaxKind.OverrideKeyword: return ModifierFlags.Override;
}
return ModifierFlags.None;
}
export function createModifiers(modifierFlags: ModifierFlags): ModifiersArray | undefined {
return modifierFlags ? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
}
export function isLogicalOperator(token: SyntaxKind): boolean {
return token === SyntaxKind.BarBarToken
|| token === SyntaxKind.AmpersandAmpersandToken
+6 -1
View File
@@ -773,6 +773,10 @@ namespace ts {
return getFirstJSDocTag(node, isJSDocReadonlyTag, /*noCache*/ true);
}
export function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined {
return getFirstJSDocTag(node, isJSDocOverrideTag, /*noCache*/ true);
}
/** Gets the JSDoc deprecated tag for the node if present */
export function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined {
return getFirstJSDocTag(node, isJSDocDeprecatedTag);
@@ -1174,6 +1178,7 @@ namespace ts {
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.ReadonlyKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.OverrideKeyword:
return true;
}
return false;
@@ -1186,7 +1191,7 @@ namespace ts {
/* @internal */
export function isClassMemberModifier(idToken: SyntaxKind): boolean {
return isParameterPropertyModifier(idToken) || idToken === SyntaxKind.StaticKeyword;
return isParameterPropertyModifier(idToken) || idToken === SyntaxKind.StaticKeyword || idToken === SyntaxKind.OverrideKeyword;
}
export function isModifier(node: Node): node is Modifier {
+2 -1
View File
@@ -1158,6 +1158,7 @@ namespace FourSlashInterface {
case "symbol":
case "type":
case "unique":
case "override":
case "unknown":
case "global":
case "bigint":
@@ -1169,7 +1170,7 @@ namespace FourSlashInterface {
}
export const classElementKeywords: readonly ExpectedCompletionEntryObject[] =
["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set"].map(keywordEntry);
["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set", "override"].map(keywordEntry);
export const classElementInJsKeywords = getInJsKeywords(classElementKeywords);
+4
View File
@@ -18,6 +18,10 @@ namespace ts.codefix {
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command);
}
export function createCodeFixActionMaybeFixAll(fixName: string, changes: FileTextChanges[], description: DiagnosticAndArguments, fixId?: {}, fixAllDescription?: DiagnosticAndArguments, command?: CodeActionCommand) {
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command);
}
function createCodeFixActionWorker(fixName: string, description: string, changes: FileTextChanges[], fixId?: {}, fixAllDescription?: string, command?: CodeActionCommand): CodeFixAction {
return { fixName, description, changes, fixId, fixAllDescription, commands: command ? [command] : undefined };
}
@@ -0,0 +1,119 @@
/* @internal */
namespace ts.codefix {
const fixName = "fixOverrideModifier";
const fixAddOverrideId = "fixAddOverrideModifier";
const fixRemoveOverrideId = "fixRemoveOverrideModifier";
type ClassElementHasJSDoc =
| ConstructorDeclaration
| PropertyDeclaration
| MethodDeclaration
| GetAccessorDeclaration
| SetAccessorDeclaration;
const errorCodes = [
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code
];
const errorCodeFixIdMap: Record<number, [DiagnosticMessage, string | undefined, DiagnosticMessage | undefined]> = {
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code]: [
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Add_all_missing_override_modifiers,
],
[Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code]: [
Diagnostics.Remove_override_modifier, fixRemoveOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
],
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code]: [
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
],
[Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code]: [
Diagnostics.Remove_override_modifier, fixRemoveOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
]
};
registerCodeFix({
errorCodes,
getCodeActions: context => {
const { errorCode, span, sourceFile } = context;
const info = errorCodeFixIdMap[errorCode];
if (!info) return emptyArray;
const [ descriptions, fixId, fixAllDescriptions ] = info;
if (isSourceFileJS(sourceFile)) return emptyArray;
const changes = textChanges.ChangeTracker.with(context, changes => dispatchChanges(changes, context, errorCode, span.start));
return [
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions)
];
},
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
getAllCodeActions: context =>
codeFixAll(context, errorCodes, (changes, diag) => {
const { code, start, file } = diag;
const info = errorCodeFixIdMap[code];
if (!info || info[1] !== context.fixId || isSourceFileJS(file)) {
return;
}
dispatchChanges(changes, context, code, start);
})
});
function dispatchChanges(
changeTracker: textChanges.ChangeTracker,
context: CodeFixContext | CodeFixAllContext,
errorCode: number,
pos: number) {
switch (errorCode) {
case Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code:
case Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code:
return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos);
case Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code:
case Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code:
return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos);
default:
Debug.fail("Unexpected error code: " + errorCode);
}
}
function doAddOverrideModifierChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
const classElement = findContainerClassElement(sourceFile, pos);
changeTracker.insertModifierBefore(sourceFile, SyntaxKind.OverrideKeyword, classElement);
}
function doRemoveOverrideModifierChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
const classElement = findContainerClassElement(sourceFile, pos);
const overrideModifier = classElement.modifiers && find(classElement.modifiers, modifier => modifier.kind === SyntaxKind.OverrideKeyword);
Debug.assertIsDefined(overrideModifier);
changeTracker.deleteModifier(sourceFile, overrideModifier);
}
function isClassElementHasJSDoc(node: Node): node is ClassElementHasJSDoc {
switch (node.kind) {
case SyntaxKind.Constructor:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return true;
default:
return false;
}
}
function findContainerClassElement(sourceFile: SourceFile, pos: number) {
const token = getTokenAtPosition(sourceFile, pos);
const classElement = findAncestor(token, node => {
if (isClassLike(node)) return "quit";
return isClassElementHasJSDoc(node);
});
Debug.assert(classElement && isClassElementHasJSDoc(classElement));
return classElement;
}
}
@@ -83,10 +83,6 @@ namespace ts.codefix {
return isIdentifier(fieldName) ? factory.createPropertyAccessExpression(leftHead, fieldName) : factory.createElementAccessExpression(leftHead, factory.createStringLiteralFromNode(fieldName));
}
function createModifiers(modifierFlags: ModifierFlags): ModifiersArray | undefined {
return modifierFlags ? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
}
function prepareModifierFlagsForAccessor(modifierFlags: ModifierFlags): ModifierFlags {
modifierFlags &= ~ModifierFlags.Readonly; // avoid Readonly modifier because it will convert to get accessor
modifierFlags &= ~ModifierFlags.Private;
+7 -1
View File
@@ -2091,13 +2091,17 @@ namespace ts.Completions {
case "static":
classElementModifierFlags = classElementModifierFlags | ModifierFlags.Static;
break;
case "override":
classElementModifierFlags = classElementModifierFlags | ModifierFlags.Override;
break;
}
}
// No member list for private methods
if (!(classElementModifierFlags & ModifierFlags.Private)) {
// List of property symbols of base type that are not private and already implemented
const baseSymbols = flatMap(getAllSuperTypeNodes(decl), baseTypeNode => {
const baseTypeNodes = isClassLike(decl) && classElementModifierFlags & ModifierFlags.Override ? singleElementArray(getEffectiveBaseTypeNode(decl)) : getAllSuperTypeNodes(decl);
const baseSymbols = flatMap(baseTypeNodes, baseTypeNode => {
const type = typeChecker.getTypeAtLocation(baseTypeNode);
return classElementModifierFlags & ModifierFlags.Static ?
type?.symbol && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) :
@@ -2708,6 +2712,7 @@ namespace ts.Completions {
case SyntaxKind.NeverKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.ObjectKeyword:
case SyntaxKind.OverrideKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.PublicKeyword:
@@ -2735,6 +2740,7 @@ namespace ts.Completions {
case SyntaxKind.SetKeyword:
case SyntaxKind.AsyncKeyword:
case SyntaxKind.DeclareKeyword:
case SyntaxKind.OverrideKeyword:
return true;
default:
return isClassMemberModifier(kind);
+10
View File
@@ -505,6 +505,16 @@ namespace ts.textChanges {
}
}
public insertNodeAtConstructorStartAfterSuperCall(sourceFile: SourceFile, ctr: ConstructorDeclaration, newStatement: Statement): void {
const superCallStatement = find(ctr.body!.statements, stmt => isExpressionStatement(stmt) && isSuperCall(stmt.expression));
if (!superCallStatement || !ctr.body!.multiLine) {
this.replaceConstructorBody(sourceFile, ctr, [...ctr.body!.statements, newStatement]);
}
else {
this.insertNodeAfter(sourceFile, superCallStatement, newStatement);
}
}
public insertNodeAtConstructorEnd(sourceFile: SourceFile, ctr: ConstructorDeclaration, newStatement: Statement): void {
const lastStatement = lastOrUndefined(ctr.body!.statements);
if (!lastStatement || !ctr.body!.multiLine) {
+1
View File
@@ -65,6 +65,7 @@
"codefixes/convertLiteralTypeToMappedType.ts",
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
"codefixes/importFixes.ts",
"codefixes/fixOverrideModifier.ts",
"codefixes/fixNoPropertyAccessFromIndexSignature.ts",
"codefixes/fixImplicitThis.ts",
"codefixes/fixIncorrectNamedTupleSyntax.ts",
+216 -204
View File
@@ -260,194 +260,196 @@ declare namespace ts {
FromKeyword = 153,
GlobalKeyword = 154,
BigIntKeyword = 155,
OfKeyword = 156,
QualifiedName = 157,
ComputedPropertyName = 158,
TypeParameter = 159,
Parameter = 160,
Decorator = 161,
PropertySignature = 162,
PropertyDeclaration = 163,
MethodSignature = 164,
MethodDeclaration = 165,
Constructor = 166,
GetAccessor = 167,
SetAccessor = 168,
CallSignature = 169,
ConstructSignature = 170,
IndexSignature = 171,
TypePredicate = 172,
TypeReference = 173,
FunctionType = 174,
ConstructorType = 175,
TypeQuery = 176,
TypeLiteral = 177,
ArrayType = 178,
TupleType = 179,
OptionalType = 180,
RestType = 181,
UnionType = 182,
IntersectionType = 183,
ConditionalType = 184,
InferType = 185,
ParenthesizedType = 186,
ThisType = 187,
TypeOperator = 188,
IndexedAccessType = 189,
MappedType = 190,
LiteralType = 191,
NamedTupleMember = 192,
TemplateLiteralType = 193,
TemplateLiteralTypeSpan = 194,
ImportType = 195,
ObjectBindingPattern = 196,
ArrayBindingPattern = 197,
BindingElement = 198,
ArrayLiteralExpression = 199,
ObjectLiteralExpression = 200,
PropertyAccessExpression = 201,
ElementAccessExpression = 202,
CallExpression = 203,
NewExpression = 204,
TaggedTemplateExpression = 205,
TypeAssertionExpression = 206,
ParenthesizedExpression = 207,
FunctionExpression = 208,
ArrowFunction = 209,
DeleteExpression = 210,
TypeOfExpression = 211,
VoidExpression = 212,
AwaitExpression = 213,
PrefixUnaryExpression = 214,
PostfixUnaryExpression = 215,
BinaryExpression = 216,
ConditionalExpression = 217,
TemplateExpression = 218,
YieldExpression = 219,
SpreadElement = 220,
ClassExpression = 221,
OmittedExpression = 222,
ExpressionWithTypeArguments = 223,
AsExpression = 224,
NonNullExpression = 225,
MetaProperty = 226,
SyntheticExpression = 227,
TemplateSpan = 228,
SemicolonClassElement = 229,
Block = 230,
EmptyStatement = 231,
VariableStatement = 232,
ExpressionStatement = 233,
IfStatement = 234,
DoStatement = 235,
WhileStatement = 236,
ForStatement = 237,
ForInStatement = 238,
ForOfStatement = 239,
ContinueStatement = 240,
BreakStatement = 241,
ReturnStatement = 242,
WithStatement = 243,
SwitchStatement = 244,
LabeledStatement = 245,
ThrowStatement = 246,
TryStatement = 247,
DebuggerStatement = 248,
VariableDeclaration = 249,
VariableDeclarationList = 250,
FunctionDeclaration = 251,
ClassDeclaration = 252,
InterfaceDeclaration = 253,
TypeAliasDeclaration = 254,
EnumDeclaration = 255,
ModuleDeclaration = 256,
ModuleBlock = 257,
CaseBlock = 258,
NamespaceExportDeclaration = 259,
ImportEqualsDeclaration = 260,
ImportDeclaration = 261,
ImportClause = 262,
NamespaceImport = 263,
NamedImports = 264,
ImportSpecifier = 265,
ExportAssignment = 266,
ExportDeclaration = 267,
NamedExports = 268,
NamespaceExport = 269,
ExportSpecifier = 270,
MissingDeclaration = 271,
ExternalModuleReference = 272,
JsxElement = 273,
JsxSelfClosingElement = 274,
JsxOpeningElement = 275,
JsxClosingElement = 276,
JsxFragment = 277,
JsxOpeningFragment = 278,
JsxClosingFragment = 279,
JsxAttribute = 280,
JsxAttributes = 281,
JsxSpreadAttribute = 282,
JsxExpression = 283,
CaseClause = 284,
DefaultClause = 285,
HeritageClause = 286,
CatchClause = 287,
PropertyAssignment = 288,
ShorthandPropertyAssignment = 289,
SpreadAssignment = 290,
EnumMember = 291,
UnparsedPrologue = 292,
UnparsedPrepend = 293,
UnparsedText = 294,
UnparsedInternalText = 295,
UnparsedSyntheticReference = 296,
SourceFile = 297,
Bundle = 298,
UnparsedSource = 299,
InputFiles = 300,
JSDocTypeExpression = 301,
JSDocNameReference = 302,
JSDocAllType = 303,
JSDocUnknownType = 304,
JSDocNullableType = 305,
JSDocNonNullableType = 306,
JSDocOptionalType = 307,
JSDocFunctionType = 308,
JSDocVariadicType = 309,
JSDocNamepathType = 310,
JSDocComment = 311,
JSDocText = 312,
JSDocTypeLiteral = 313,
JSDocSignature = 314,
JSDocLink = 315,
JSDocTag = 316,
JSDocAugmentsTag = 317,
JSDocImplementsTag = 318,
JSDocAuthorTag = 319,
JSDocDeprecatedTag = 320,
JSDocClassTag = 321,
JSDocPublicTag = 322,
JSDocPrivateTag = 323,
JSDocProtectedTag = 324,
JSDocReadonlyTag = 325,
JSDocCallbackTag = 326,
JSDocEnumTag = 327,
JSDocParameterTag = 328,
JSDocReturnTag = 329,
JSDocThisTag = 330,
JSDocTypeTag = 331,
JSDocTemplateTag = 332,
JSDocTypedefTag = 333,
JSDocSeeTag = 334,
JSDocPropertyTag = 335,
SyntaxList = 336,
NotEmittedStatement = 337,
PartiallyEmittedExpression = 338,
CommaListExpression = 339,
MergeDeclarationMarker = 340,
EndOfDeclarationMarker = 341,
SyntheticReferenceExpression = 342,
Count = 343,
OverrideKeyword = 156,
OfKeyword = 157,
QualifiedName = 158,
ComputedPropertyName = 159,
TypeParameter = 160,
Parameter = 161,
Decorator = 162,
PropertySignature = 163,
PropertyDeclaration = 164,
MethodSignature = 165,
MethodDeclaration = 166,
Constructor = 167,
GetAccessor = 168,
SetAccessor = 169,
CallSignature = 170,
ConstructSignature = 171,
IndexSignature = 172,
TypePredicate = 173,
TypeReference = 174,
FunctionType = 175,
ConstructorType = 176,
TypeQuery = 177,
TypeLiteral = 178,
ArrayType = 179,
TupleType = 180,
OptionalType = 181,
RestType = 182,
UnionType = 183,
IntersectionType = 184,
ConditionalType = 185,
InferType = 186,
ParenthesizedType = 187,
ThisType = 188,
TypeOperator = 189,
IndexedAccessType = 190,
MappedType = 191,
LiteralType = 192,
NamedTupleMember = 193,
TemplateLiteralType = 194,
TemplateLiteralTypeSpan = 195,
ImportType = 196,
ObjectBindingPattern = 197,
ArrayBindingPattern = 198,
BindingElement = 199,
ArrayLiteralExpression = 200,
ObjectLiteralExpression = 201,
PropertyAccessExpression = 202,
ElementAccessExpression = 203,
CallExpression = 204,
NewExpression = 205,
TaggedTemplateExpression = 206,
TypeAssertionExpression = 207,
ParenthesizedExpression = 208,
FunctionExpression = 209,
ArrowFunction = 210,
DeleteExpression = 211,
TypeOfExpression = 212,
VoidExpression = 213,
AwaitExpression = 214,
PrefixUnaryExpression = 215,
PostfixUnaryExpression = 216,
BinaryExpression = 217,
ConditionalExpression = 218,
TemplateExpression = 219,
YieldExpression = 220,
SpreadElement = 221,
ClassExpression = 222,
OmittedExpression = 223,
ExpressionWithTypeArguments = 224,
AsExpression = 225,
NonNullExpression = 226,
MetaProperty = 227,
SyntheticExpression = 228,
TemplateSpan = 229,
SemicolonClassElement = 230,
Block = 231,
EmptyStatement = 232,
VariableStatement = 233,
ExpressionStatement = 234,
IfStatement = 235,
DoStatement = 236,
WhileStatement = 237,
ForStatement = 238,
ForInStatement = 239,
ForOfStatement = 240,
ContinueStatement = 241,
BreakStatement = 242,
ReturnStatement = 243,
WithStatement = 244,
SwitchStatement = 245,
LabeledStatement = 246,
ThrowStatement = 247,
TryStatement = 248,
DebuggerStatement = 249,
VariableDeclaration = 250,
VariableDeclarationList = 251,
FunctionDeclaration = 252,
ClassDeclaration = 253,
InterfaceDeclaration = 254,
TypeAliasDeclaration = 255,
EnumDeclaration = 256,
ModuleDeclaration = 257,
ModuleBlock = 258,
CaseBlock = 259,
NamespaceExportDeclaration = 260,
ImportEqualsDeclaration = 261,
ImportDeclaration = 262,
ImportClause = 263,
NamespaceImport = 264,
NamedImports = 265,
ImportSpecifier = 266,
ExportAssignment = 267,
ExportDeclaration = 268,
NamedExports = 269,
NamespaceExport = 270,
ExportSpecifier = 271,
MissingDeclaration = 272,
ExternalModuleReference = 273,
JsxElement = 274,
JsxSelfClosingElement = 275,
JsxOpeningElement = 276,
JsxClosingElement = 277,
JsxFragment = 278,
JsxOpeningFragment = 279,
JsxClosingFragment = 280,
JsxAttribute = 281,
JsxAttributes = 282,
JsxSpreadAttribute = 283,
JsxExpression = 284,
CaseClause = 285,
DefaultClause = 286,
HeritageClause = 287,
CatchClause = 288,
PropertyAssignment = 289,
ShorthandPropertyAssignment = 290,
SpreadAssignment = 291,
EnumMember = 292,
UnparsedPrologue = 293,
UnparsedPrepend = 294,
UnparsedText = 295,
UnparsedInternalText = 296,
UnparsedSyntheticReference = 297,
SourceFile = 298,
Bundle = 299,
UnparsedSource = 300,
InputFiles = 301,
JSDocTypeExpression = 302,
JSDocNameReference = 303,
JSDocAllType = 304,
JSDocUnknownType = 305,
JSDocNullableType = 306,
JSDocNonNullableType = 307,
JSDocOptionalType = 308,
JSDocFunctionType = 309,
JSDocVariadicType = 310,
JSDocNamepathType = 311,
JSDocComment = 312,
JSDocText = 313,
JSDocTypeLiteral = 314,
JSDocSignature = 315,
JSDocLink = 316,
JSDocTag = 317,
JSDocAugmentsTag = 318,
JSDocImplementsTag = 319,
JSDocAuthorTag = 320,
JSDocDeprecatedTag = 321,
JSDocClassTag = 322,
JSDocPublicTag = 323,
JSDocPrivateTag = 324,
JSDocProtectedTag = 325,
JSDocReadonlyTag = 326,
JSDocOverrideTag = 327,
JSDocCallbackTag = 328,
JSDocEnumTag = 329,
JSDocParameterTag = 330,
JSDocReturnTag = 331,
JSDocThisTag = 332,
JSDocTypeTag = 333,
JSDocTemplateTag = 334,
JSDocTypedefTag = 335,
JSDocSeeTag = 336,
JSDocPropertyTag = 337,
SyntaxList = 338,
NotEmittedStatement = 339,
PartiallyEmittedExpression = 340,
CommaListExpression = 341,
MergeDeclarationMarker = 342,
EndOfDeclarationMarker = 343,
SyntheticReferenceExpression = 344,
Count = 345,
FirstAssignment = 62,
LastAssignment = 77,
FirstCompoundAssignment = 63,
@@ -455,15 +457,15 @@ declare namespace ts {
FirstReservedWord = 80,
LastReservedWord = 115,
FirstKeyword = 80,
LastKeyword = 156,
LastKeyword = 157,
FirstFutureReservedWord = 116,
LastFutureReservedWord = 124,
FirstTypeNode = 172,
LastTypeNode = 195,
FirstTypeNode = 173,
LastTypeNode = 196,
FirstPunctuation = 18,
LastPunctuation = 77,
FirstToken = 0,
LastToken = 156,
LastToken = 157,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -472,20 +474,20 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 77,
FirstStatement = 232,
LastStatement = 248,
FirstNode = 157,
FirstJSDocNode = 301,
LastJSDocNode = 335,
FirstJSDocTagNode = 316,
LastJSDocTagNode = 335,
FirstStatement = 233,
LastStatement = 249,
FirstNode = 158,
FirstJSDocNode = 302,
LastJSDocNode = 337,
FirstJSDocTagNode = 317,
LastJSDocTagNode = 337,
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | 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.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | 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;
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.StaticKeyword;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | 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.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | 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;
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
@@ -535,13 +537,14 @@ declare namespace ts {
Const = 2048,
HasComputedJSDocModifiers = 4096,
Deprecated = 8192,
Override = 16384,
HasComputedFlags = 536870912,
AccessibilityModifier = 28,
ParameterPropertyModifier = 92,
NonPublicAccessibilityModifier = 24,
TypeScriptModifier = 2270,
TypeScriptModifier = 18654,
ExportDefault = 513,
All = 11263
All = 27647
}
export enum JsxFlags {
None = 0,
@@ -605,10 +608,11 @@ declare namespace ts {
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
/** @deprecated Use `ReadonlyKeyword` instead. */
export type ReadonlyToken = ReadonlyKeyword;
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | ReadonlyKeyword | StaticKeyword;
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword;
export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword;
export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword;
@@ -1801,6 +1805,9 @@ declare namespace ts {
export interface JSDocReadonlyTag extends JSDocTag {
readonly kind: SyntaxKind.JSDocReadonlyTag;
}
export interface JSDocOverrideTag extends JSDocTag {
readonly kind: SyntaxKind.JSDocOverrideTag;
}
export interface JSDocEnumTag extends JSDocTag, Declaration {
readonly kind: SyntaxKind.JSDocEnumTag;
readonly parent: JSDoc;
@@ -2861,6 +2868,7 @@ declare namespace ts {
outFile?: string;
paths?: MapLike<string[]>;
preserveConstEnums?: boolean;
noImplicitOverride?: boolean;
preserveSymlinks?: boolean;
project?: string;
reactNamespace?: string;
@@ -3535,6 +3543,8 @@ declare namespace ts {
updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocText | JSDocLink> | undefined): JSDocUnknownTag;
createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocDeprecatedTag;
updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocDeprecatedTag;
createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocOverrideTag;
updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocOverrideTag;
createJSDocText(text: string): JSDocText;
updateJSDocText(node: JSDocText, text: string): JSDocText;
createJSDocComment(comment?: string | NodeArray<JSDocText | JSDocLink> | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc;
@@ -4186,6 +4196,7 @@ declare namespace ts {
function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined;
/** Gets the JSDoc protected tag for the node if present */
function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined;
function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined;
/** Gets the JSDoc deprecated tag for the node if present */
function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined;
/** Gets the JSDoc enum tag for the node if present */
@@ -4564,6 +4575,7 @@ declare namespace ts {
function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag;
function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag;
function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag;
function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag;
function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag;
function isJSDocSeeTag(node: Node): node is JSDocSeeTag;
function isJSDocEnumTag(node: Node): node is JSDocEnumTag;
+216 -204
View File
@@ -260,194 +260,196 @@ declare namespace ts {
FromKeyword = 153,
GlobalKeyword = 154,
BigIntKeyword = 155,
OfKeyword = 156,
QualifiedName = 157,
ComputedPropertyName = 158,
TypeParameter = 159,
Parameter = 160,
Decorator = 161,
PropertySignature = 162,
PropertyDeclaration = 163,
MethodSignature = 164,
MethodDeclaration = 165,
Constructor = 166,
GetAccessor = 167,
SetAccessor = 168,
CallSignature = 169,
ConstructSignature = 170,
IndexSignature = 171,
TypePredicate = 172,
TypeReference = 173,
FunctionType = 174,
ConstructorType = 175,
TypeQuery = 176,
TypeLiteral = 177,
ArrayType = 178,
TupleType = 179,
OptionalType = 180,
RestType = 181,
UnionType = 182,
IntersectionType = 183,
ConditionalType = 184,
InferType = 185,
ParenthesizedType = 186,
ThisType = 187,
TypeOperator = 188,
IndexedAccessType = 189,
MappedType = 190,
LiteralType = 191,
NamedTupleMember = 192,
TemplateLiteralType = 193,
TemplateLiteralTypeSpan = 194,
ImportType = 195,
ObjectBindingPattern = 196,
ArrayBindingPattern = 197,
BindingElement = 198,
ArrayLiteralExpression = 199,
ObjectLiteralExpression = 200,
PropertyAccessExpression = 201,
ElementAccessExpression = 202,
CallExpression = 203,
NewExpression = 204,
TaggedTemplateExpression = 205,
TypeAssertionExpression = 206,
ParenthesizedExpression = 207,
FunctionExpression = 208,
ArrowFunction = 209,
DeleteExpression = 210,
TypeOfExpression = 211,
VoidExpression = 212,
AwaitExpression = 213,
PrefixUnaryExpression = 214,
PostfixUnaryExpression = 215,
BinaryExpression = 216,
ConditionalExpression = 217,
TemplateExpression = 218,
YieldExpression = 219,
SpreadElement = 220,
ClassExpression = 221,
OmittedExpression = 222,
ExpressionWithTypeArguments = 223,
AsExpression = 224,
NonNullExpression = 225,
MetaProperty = 226,
SyntheticExpression = 227,
TemplateSpan = 228,
SemicolonClassElement = 229,
Block = 230,
EmptyStatement = 231,
VariableStatement = 232,
ExpressionStatement = 233,
IfStatement = 234,
DoStatement = 235,
WhileStatement = 236,
ForStatement = 237,
ForInStatement = 238,
ForOfStatement = 239,
ContinueStatement = 240,
BreakStatement = 241,
ReturnStatement = 242,
WithStatement = 243,
SwitchStatement = 244,
LabeledStatement = 245,
ThrowStatement = 246,
TryStatement = 247,
DebuggerStatement = 248,
VariableDeclaration = 249,
VariableDeclarationList = 250,
FunctionDeclaration = 251,
ClassDeclaration = 252,
InterfaceDeclaration = 253,
TypeAliasDeclaration = 254,
EnumDeclaration = 255,
ModuleDeclaration = 256,
ModuleBlock = 257,
CaseBlock = 258,
NamespaceExportDeclaration = 259,
ImportEqualsDeclaration = 260,
ImportDeclaration = 261,
ImportClause = 262,
NamespaceImport = 263,
NamedImports = 264,
ImportSpecifier = 265,
ExportAssignment = 266,
ExportDeclaration = 267,
NamedExports = 268,
NamespaceExport = 269,
ExportSpecifier = 270,
MissingDeclaration = 271,
ExternalModuleReference = 272,
JsxElement = 273,
JsxSelfClosingElement = 274,
JsxOpeningElement = 275,
JsxClosingElement = 276,
JsxFragment = 277,
JsxOpeningFragment = 278,
JsxClosingFragment = 279,
JsxAttribute = 280,
JsxAttributes = 281,
JsxSpreadAttribute = 282,
JsxExpression = 283,
CaseClause = 284,
DefaultClause = 285,
HeritageClause = 286,
CatchClause = 287,
PropertyAssignment = 288,
ShorthandPropertyAssignment = 289,
SpreadAssignment = 290,
EnumMember = 291,
UnparsedPrologue = 292,
UnparsedPrepend = 293,
UnparsedText = 294,
UnparsedInternalText = 295,
UnparsedSyntheticReference = 296,
SourceFile = 297,
Bundle = 298,
UnparsedSource = 299,
InputFiles = 300,
JSDocTypeExpression = 301,
JSDocNameReference = 302,
JSDocAllType = 303,
JSDocUnknownType = 304,
JSDocNullableType = 305,
JSDocNonNullableType = 306,
JSDocOptionalType = 307,
JSDocFunctionType = 308,
JSDocVariadicType = 309,
JSDocNamepathType = 310,
JSDocComment = 311,
JSDocText = 312,
JSDocTypeLiteral = 313,
JSDocSignature = 314,
JSDocLink = 315,
JSDocTag = 316,
JSDocAugmentsTag = 317,
JSDocImplementsTag = 318,
JSDocAuthorTag = 319,
JSDocDeprecatedTag = 320,
JSDocClassTag = 321,
JSDocPublicTag = 322,
JSDocPrivateTag = 323,
JSDocProtectedTag = 324,
JSDocReadonlyTag = 325,
JSDocCallbackTag = 326,
JSDocEnumTag = 327,
JSDocParameterTag = 328,
JSDocReturnTag = 329,
JSDocThisTag = 330,
JSDocTypeTag = 331,
JSDocTemplateTag = 332,
JSDocTypedefTag = 333,
JSDocSeeTag = 334,
JSDocPropertyTag = 335,
SyntaxList = 336,
NotEmittedStatement = 337,
PartiallyEmittedExpression = 338,
CommaListExpression = 339,
MergeDeclarationMarker = 340,
EndOfDeclarationMarker = 341,
SyntheticReferenceExpression = 342,
Count = 343,
OverrideKeyword = 156,
OfKeyword = 157,
QualifiedName = 158,
ComputedPropertyName = 159,
TypeParameter = 160,
Parameter = 161,
Decorator = 162,
PropertySignature = 163,
PropertyDeclaration = 164,
MethodSignature = 165,
MethodDeclaration = 166,
Constructor = 167,
GetAccessor = 168,
SetAccessor = 169,
CallSignature = 170,
ConstructSignature = 171,
IndexSignature = 172,
TypePredicate = 173,
TypeReference = 174,
FunctionType = 175,
ConstructorType = 176,
TypeQuery = 177,
TypeLiteral = 178,
ArrayType = 179,
TupleType = 180,
OptionalType = 181,
RestType = 182,
UnionType = 183,
IntersectionType = 184,
ConditionalType = 185,
InferType = 186,
ParenthesizedType = 187,
ThisType = 188,
TypeOperator = 189,
IndexedAccessType = 190,
MappedType = 191,
LiteralType = 192,
NamedTupleMember = 193,
TemplateLiteralType = 194,
TemplateLiteralTypeSpan = 195,
ImportType = 196,
ObjectBindingPattern = 197,
ArrayBindingPattern = 198,
BindingElement = 199,
ArrayLiteralExpression = 200,
ObjectLiteralExpression = 201,
PropertyAccessExpression = 202,
ElementAccessExpression = 203,
CallExpression = 204,
NewExpression = 205,
TaggedTemplateExpression = 206,
TypeAssertionExpression = 207,
ParenthesizedExpression = 208,
FunctionExpression = 209,
ArrowFunction = 210,
DeleteExpression = 211,
TypeOfExpression = 212,
VoidExpression = 213,
AwaitExpression = 214,
PrefixUnaryExpression = 215,
PostfixUnaryExpression = 216,
BinaryExpression = 217,
ConditionalExpression = 218,
TemplateExpression = 219,
YieldExpression = 220,
SpreadElement = 221,
ClassExpression = 222,
OmittedExpression = 223,
ExpressionWithTypeArguments = 224,
AsExpression = 225,
NonNullExpression = 226,
MetaProperty = 227,
SyntheticExpression = 228,
TemplateSpan = 229,
SemicolonClassElement = 230,
Block = 231,
EmptyStatement = 232,
VariableStatement = 233,
ExpressionStatement = 234,
IfStatement = 235,
DoStatement = 236,
WhileStatement = 237,
ForStatement = 238,
ForInStatement = 239,
ForOfStatement = 240,
ContinueStatement = 241,
BreakStatement = 242,
ReturnStatement = 243,
WithStatement = 244,
SwitchStatement = 245,
LabeledStatement = 246,
ThrowStatement = 247,
TryStatement = 248,
DebuggerStatement = 249,
VariableDeclaration = 250,
VariableDeclarationList = 251,
FunctionDeclaration = 252,
ClassDeclaration = 253,
InterfaceDeclaration = 254,
TypeAliasDeclaration = 255,
EnumDeclaration = 256,
ModuleDeclaration = 257,
ModuleBlock = 258,
CaseBlock = 259,
NamespaceExportDeclaration = 260,
ImportEqualsDeclaration = 261,
ImportDeclaration = 262,
ImportClause = 263,
NamespaceImport = 264,
NamedImports = 265,
ImportSpecifier = 266,
ExportAssignment = 267,
ExportDeclaration = 268,
NamedExports = 269,
NamespaceExport = 270,
ExportSpecifier = 271,
MissingDeclaration = 272,
ExternalModuleReference = 273,
JsxElement = 274,
JsxSelfClosingElement = 275,
JsxOpeningElement = 276,
JsxClosingElement = 277,
JsxFragment = 278,
JsxOpeningFragment = 279,
JsxClosingFragment = 280,
JsxAttribute = 281,
JsxAttributes = 282,
JsxSpreadAttribute = 283,
JsxExpression = 284,
CaseClause = 285,
DefaultClause = 286,
HeritageClause = 287,
CatchClause = 288,
PropertyAssignment = 289,
ShorthandPropertyAssignment = 290,
SpreadAssignment = 291,
EnumMember = 292,
UnparsedPrologue = 293,
UnparsedPrepend = 294,
UnparsedText = 295,
UnparsedInternalText = 296,
UnparsedSyntheticReference = 297,
SourceFile = 298,
Bundle = 299,
UnparsedSource = 300,
InputFiles = 301,
JSDocTypeExpression = 302,
JSDocNameReference = 303,
JSDocAllType = 304,
JSDocUnknownType = 305,
JSDocNullableType = 306,
JSDocNonNullableType = 307,
JSDocOptionalType = 308,
JSDocFunctionType = 309,
JSDocVariadicType = 310,
JSDocNamepathType = 311,
JSDocComment = 312,
JSDocText = 313,
JSDocTypeLiteral = 314,
JSDocSignature = 315,
JSDocLink = 316,
JSDocTag = 317,
JSDocAugmentsTag = 318,
JSDocImplementsTag = 319,
JSDocAuthorTag = 320,
JSDocDeprecatedTag = 321,
JSDocClassTag = 322,
JSDocPublicTag = 323,
JSDocPrivateTag = 324,
JSDocProtectedTag = 325,
JSDocReadonlyTag = 326,
JSDocOverrideTag = 327,
JSDocCallbackTag = 328,
JSDocEnumTag = 329,
JSDocParameterTag = 330,
JSDocReturnTag = 331,
JSDocThisTag = 332,
JSDocTypeTag = 333,
JSDocTemplateTag = 334,
JSDocTypedefTag = 335,
JSDocSeeTag = 336,
JSDocPropertyTag = 337,
SyntaxList = 338,
NotEmittedStatement = 339,
PartiallyEmittedExpression = 340,
CommaListExpression = 341,
MergeDeclarationMarker = 342,
EndOfDeclarationMarker = 343,
SyntheticReferenceExpression = 344,
Count = 345,
FirstAssignment = 62,
LastAssignment = 77,
FirstCompoundAssignment = 63,
@@ -455,15 +457,15 @@ declare namespace ts {
FirstReservedWord = 80,
LastReservedWord = 115,
FirstKeyword = 80,
LastKeyword = 156,
LastKeyword = 157,
FirstFutureReservedWord = 116,
LastFutureReservedWord = 124,
FirstTypeNode = 172,
LastTypeNode = 195,
FirstTypeNode = 173,
LastTypeNode = 196,
FirstPunctuation = 18,
LastPunctuation = 77,
FirstToken = 0,
LastToken = 156,
LastToken = 157,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -472,20 +474,20 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 77,
FirstStatement = 232,
LastStatement = 248,
FirstNode = 157,
FirstJSDocNode = 301,
LastJSDocNode = 335,
FirstJSDocTagNode = 316,
LastJSDocTagNode = 335,
FirstStatement = 233,
LastStatement = 249,
FirstNode = 158,
FirstJSDocNode = 302,
LastJSDocNode = 337,
FirstJSDocTagNode = 317,
LastJSDocTagNode = 337,
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | 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.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | 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;
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.StaticKeyword;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | 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.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | 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;
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
@@ -535,13 +537,14 @@ declare namespace ts {
Const = 2048,
HasComputedJSDocModifiers = 4096,
Deprecated = 8192,
Override = 16384,
HasComputedFlags = 536870912,
AccessibilityModifier = 28,
ParameterPropertyModifier = 92,
NonPublicAccessibilityModifier = 24,
TypeScriptModifier = 2270,
TypeScriptModifier = 18654,
ExportDefault = 513,
All = 11263
All = 27647
}
export enum JsxFlags {
None = 0,
@@ -605,10 +608,11 @@ declare namespace ts {
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
/** @deprecated Use `ReadonlyKeyword` instead. */
export type ReadonlyToken = ReadonlyKeyword;
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | ReadonlyKeyword | StaticKeyword;
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword;
export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword;
export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword;
@@ -1801,6 +1805,9 @@ declare namespace ts {
export interface JSDocReadonlyTag extends JSDocTag {
readonly kind: SyntaxKind.JSDocReadonlyTag;
}
export interface JSDocOverrideTag extends JSDocTag {
readonly kind: SyntaxKind.JSDocOverrideTag;
}
export interface JSDocEnumTag extends JSDocTag, Declaration {
readonly kind: SyntaxKind.JSDocEnumTag;
readonly parent: JSDoc;
@@ -2861,6 +2868,7 @@ declare namespace ts {
outFile?: string;
paths?: MapLike<string[]>;
preserveConstEnums?: boolean;
noImplicitOverride?: boolean;
preserveSymlinks?: boolean;
project?: string;
reactNamespace?: string;
@@ -3535,6 +3543,8 @@ declare namespace ts {
updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocText | JSDocLink> | undefined): JSDocUnknownTag;
createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocDeprecatedTag;
updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocDeprecatedTag;
createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocOverrideTag;
updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray<JSDocText | JSDocLink>): JSDocOverrideTag;
createJSDocText(text: string): JSDocText;
updateJSDocText(node: JSDocText, text: string): JSDocText;
createJSDocComment(comment?: string | NodeArray<JSDocText | JSDocLink> | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc;
@@ -4186,6 +4196,7 @@ declare namespace ts {
function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined;
/** Gets the JSDoc protected tag for the node if present */
function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined;
function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined;
/** Gets the JSDoc deprecated tag for the node if present */
function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined;
/** Gets the JSDoc enum tag for the node if present */
@@ -4564,6 +4575,7 @@ declare namespace ts {
function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag;
function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag;
function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag;
function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag;
function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag;
function isJSDocSeeTag(node: Node): node is JSDocSeeTag;
function isJSDocEnumTag(node: Node): node is JSDocEnumTag;
@@ -0,0 +1,55 @@
tests/cases/conformance/jsdoc/0.js(27,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'.
tests/cases/conformance/jsdoc/0.js(32,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'A'.
tests/cases/conformance/jsdoc/0.js(40,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
==== tests/cases/conformance/jsdoc/0.js (3 errors) ====
class A {
/**
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
return typeof a === 'string'
}
bar () {
}
}
class B extends A {
/**
* @override
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
return super.foo(a)
}
bar () {
~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'.
}
/** @override */
baz () {
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'A'.
}
}
class C {
/** @override */
foo () {
~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
}
}
@@ -0,0 +1,65 @@
=== tests/cases/conformance/jsdoc/0.js ===
class A {
>A : Symbol(A, Decl(0.js, 0, 0))
/**
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
>foo : Symbol(A.foo, Decl(0.js, 0, 9))
>a : Symbol(a, Decl(0.js, 7, 9))
return typeof a === 'string'
>a : Symbol(a, Decl(0.js, 7, 9))
}
bar () {
>bar : Symbol(A.bar, Decl(0.js, 9, 5))
}
}
class B extends A {
>B : Symbol(B, Decl(0.js, 13, 1))
>A : Symbol(A, Decl(0.js, 0, 0))
/**
* @override
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
>foo : Symbol(B.foo, Decl(0.js, 15, 19))
>a : Symbol(a, Decl(0.js, 22, 9))
return super.foo(a)
>super.foo : Symbol(A.foo, Decl(0.js, 0, 9))
>super : Symbol(A, Decl(0.js, 0, 0))
>foo : Symbol(A.foo, Decl(0.js, 0, 9))
>a : Symbol(a, Decl(0.js, 22, 9))
}
bar () {
>bar : Symbol(B.bar, Decl(0.js, 24, 5))
}
/** @override */
baz () {
>baz : Symbol(B.baz, Decl(0.js, 28, 5))
}
}
class C {
>C : Symbol(C, Decl(0.js, 34, 1))
/** @override */
foo () {
>foo : Symbol(C.foo, Decl(0.js, 37, 9))
}
}
@@ -0,0 +1,69 @@
=== tests/cases/conformance/jsdoc/0.js ===
class A {
>A : A
/**
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
>foo : (a: string | number) => boolean
>a : string | number
return typeof a === 'string'
>typeof a === 'string' : boolean
>typeof a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>a : string | number
>'string' : "string"
}
bar () {
>bar : () => void
}
}
class B extends A {
>B : B
>A : A
/**
* @override
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
>foo : (a: string | number) => boolean
>a : string | number
return super.foo(a)
>super.foo(a) : boolean
>super.foo : (a: string | number) => boolean
>super : A
>foo : (a: string | number) => boolean
>a : string | number
}
bar () {
>bar : () => void
}
/** @override */
baz () {
>baz : () => void
}
}
class C {
>C : C
/** @override */
foo () {
>foo : () => void
}
}
@@ -0,0 +1,71 @@
tests/cases/conformance/override/override1.ts(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override1.ts(11,14): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
tests/cases/conformance/override/override1.ts(15,14): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
tests/cases/conformance/override/override1.ts(22,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override1.ts(24,18): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
tests/cases/conformance/override/override1.ts(33,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class '(Anonymous class)'.
tests/cases/conformance/override/override1.ts(37,14): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class '(Anonymous class)'.
tests/cases/conformance/override/override1.ts(42,18): error TS4112: This member cannot have an 'override' modifier because its containing class '(Anonymous class)' does not extend another class.
==== tests/cases/conformance/override/override1.ts (8 errors) ====
class B {
foo (v: string) {}
fooo (v: string) {}
}
class D extends B {
override foo (v: string) {}
fooo (v: string) {}
~~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
override bar(v: string) {}
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
}
class C {
override foo(v: string) {}
~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
}
function f () {
return class extends B {
override foo (v: string) {}
fooo (v: string) {}
~~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
override bar(v: string) {}
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
}
}
class E extends (class {
foo () { }
bar () { }
}) {
override foo () { }
bar () { }
~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class '(Anonymous class)'.
baz() {}
override bazz () {}
~~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class '(Anonymous class)'.
}
function ff () {
return class {
override foo () {}
~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class '(Anonymous class)' does not extend another class.
}
}
+161
View File
@@ -0,0 +1,161 @@
//// [override1.ts]
class B {
foo (v: string) {}
fooo (v: string) {}
}
class D extends B {
override foo (v: string) {}
fooo (v: string) {}
override bar(v: string) {}
}
class C {
override foo(v: string) {}
}
function f () {
return class extends B {
override foo (v: string) {}
fooo (v: string) {}
override bar(v: string) {}
}
}
class E extends (class {
foo () { }
bar () { }
}) {
override foo () { }
bar () { }
baz() {}
override bazz () {}
}
function ff () {
return class {
override foo () {}
}
}
//// [override1.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B() {
}
B.prototype.foo = function (v) { };
B.prototype.fooo = function (v) { };
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D() {
return _super !== null && _super.apply(this, arguments) || this;
}
D.prototype.foo = function (v) { };
D.prototype.fooo = function (v) { };
D.prototype.bar = function (v) { };
return D;
}(B));
var C = /** @class */ (function () {
function C() {
}
C.prototype.foo = function (v) { };
return C;
}());
function f() {
return /** @class */ (function (_super) {
__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.foo = function (v) { };
class_1.prototype.fooo = function (v) { };
class_1.prototype.bar = function (v) { };
return class_1;
}(B));
}
var E = /** @class */ (function (_super) {
__extends(E, _super);
function E() {
return _super !== null && _super.apply(this, arguments) || this;
}
E.prototype.foo = function () { };
E.prototype.bar = function () { };
E.prototype.baz = function () { };
E.prototype.bazz = function () { };
return E;
}((/** @class */ (function () {
function class_2() {
}
class_2.prototype.foo = function () { };
class_2.prototype.bar = function () { };
return class_2;
}()))));
function ff() {
return /** @class */ (function () {
function class_3() {
}
class_3.prototype.foo = function () { };
return class_3;
}());
}
//// [override1.d.ts]
declare class B {
foo(v: string): void;
fooo(v: string): void;
}
declare class D extends B {
foo(v: string): void;
fooo(v: string): void;
bar(v: string): void;
}
declare class C {
foo(v: string): void;
}
declare function f(): {
new (): {
foo(v: string): void;
fooo(v: string): void;
bar(v: string): void;
};
};
declare const E_base: {
new (): {
foo(): void;
bar(): void;
};
};
declare class E extends E_base {
foo(): void;
bar(): void;
baz(): void;
bazz(): void;
}
declare function ff(): {
new (): {
foo(): void;
};
};
@@ -0,0 +1,89 @@
=== tests/cases/conformance/override/override1.ts ===
class B {
>B : Symbol(B, Decl(override1.ts, 0, 0))
foo (v: string) {}
>foo : Symbol(B.foo, Decl(override1.ts, 0, 9))
>v : Symbol(v, Decl(override1.ts, 1, 9))
fooo (v: string) {}
>fooo : Symbol(B.fooo, Decl(override1.ts, 1, 22))
>v : Symbol(v, Decl(override1.ts, 2, 10))
}
class D extends B {
>D : Symbol(D, Decl(override1.ts, 3, 1))
>B : Symbol(B, Decl(override1.ts, 0, 0))
override foo (v: string) {}
>foo : Symbol(D.foo, Decl(override1.ts, 5, 19))
>v : Symbol(v, Decl(override1.ts, 6, 18))
fooo (v: string) {}
>fooo : Symbol(D.fooo, Decl(override1.ts, 6, 31))
>v : Symbol(v, Decl(override1.ts, 8, 10))
override bar(v: string) {}
>bar : Symbol(D.bar, Decl(override1.ts, 8, 23))
>v : Symbol(v, Decl(override1.ts, 10, 17))
}
class C {
>C : Symbol(C, Decl(override1.ts, 11, 1))
override foo(v: string) {}
>foo : Symbol(C.foo, Decl(override1.ts, 13, 9))
>v : Symbol(v, Decl(override1.ts, 14, 17))
}
function f () {
>f : Symbol(f, Decl(override1.ts, 15, 1))
return class extends B {
>B : Symbol(B, Decl(override1.ts, 0, 0))
override foo (v: string) {}
>foo : Symbol((Anonymous class).foo, Decl(override1.ts, 18, 28))
>v : Symbol(v, Decl(override1.ts, 19, 22))
fooo (v: string) {}
>fooo : Symbol((Anonymous class).fooo, Decl(override1.ts, 19, 35))
>v : Symbol(v, Decl(override1.ts, 21, 14))
override bar(v: string) {}
>bar : Symbol((Anonymous class).bar, Decl(override1.ts, 21, 27))
>v : Symbol(v, Decl(override1.ts, 23, 21))
}
}
class E extends (class {
>E : Symbol(E, Decl(override1.ts, 25, 1))
foo () { }
>foo : Symbol((Anonymous class).foo, Decl(override1.ts, 27, 24))
bar () { }
>bar : Symbol((Anonymous class).bar, Decl(override1.ts, 28, 14))
}) {
override foo () { }
>foo : Symbol(E.foo, Decl(override1.ts, 30, 4))
bar () { }
>bar : Symbol(E.bar, Decl(override1.ts, 31, 23))
baz() {}
>baz : Symbol(E.baz, Decl(override1.ts, 32, 14))
override bazz () {}
>bazz : Symbol(E.bazz, Decl(override1.ts, 34, 12))
}
function ff () {
>ff : Symbol(ff, Decl(override1.ts, 37, 1))
return class {
override foo () {}
>foo : Symbol((Anonymous class).foo, Decl(override1.ts, 40, 18))
}
}
+94
View File
@@ -0,0 +1,94 @@
=== tests/cases/conformance/override/override1.ts ===
class B {
>B : B
foo (v: string) {}
>foo : (v: string) => void
>v : string
fooo (v: string) {}
>fooo : (v: string) => void
>v : string
}
class D extends B {
>D : D
>B : B
override foo (v: string) {}
>foo : (v: string) => void
>v : string
fooo (v: string) {}
>fooo : (v: string) => void
>v : string
override bar(v: string) {}
>bar : (v: string) => void
>v : string
}
class C {
>C : C
override foo(v: string) {}
>foo : (v: string) => void
>v : string
}
function f () {
>f : () => typeof (Anonymous class)
return class extends B {
>class extends B { override foo (v: string) {} fooo (v: string) {} override bar(v: string) {} } : typeof (Anonymous class)
>B : B
override foo (v: string) {}
>foo : (v: string) => void
>v : string
fooo (v: string) {}
>fooo : (v: string) => void
>v : string
override bar(v: string) {}
>bar : (v: string) => void
>v : string
}
}
class E extends (class {
>E : E
>(class { foo () { } bar () { }}) : (Anonymous class)
>class { foo () { } bar () { }} : typeof (Anonymous class)
foo () { }
>foo : () => void
bar () { }
>bar : () => void
}) {
override foo () { }
>foo : () => void
bar () { }
>bar : () => void
baz() {}
>baz : () => void
override bazz () {}
>bazz : () => void
}
function ff () {
>ff : () => typeof (Anonymous class)
return class {
>class { override foo () {} } : typeof (Anonymous class)
override foo () {}
>foo : () => void
}
}
+53
View File
@@ -0,0 +1,53 @@
//// [override10.ts]
abstract class Base {
abstract foo(): unknown;
abstract bar(): void;
}
// No errors:
abstract class Sub extends Base {
override abstract foo(): number;
bar() { }
}
//// [override10.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Base = /** @class */ (function () {
function Base() {
}
return Base;
}());
// No errors:
var Sub = /** @class */ (function (_super) {
__extends(Sub, _super);
function Sub() {
return _super !== null && _super.apply(this, arguments) || this;
}
Sub.prototype.bar = function () { };
return Sub;
}(Base));
//// [override10.d.ts]
declare abstract class Base {
abstract foo(): unknown;
abstract bar(): void;
}
declare abstract class Sub extends Base {
abstract foo(): number;
bar(): void;
}
@@ -0,0 +1,22 @@
=== tests/cases/conformance/override/override10.ts ===
abstract class Base {
>Base : Symbol(Base, Decl(override10.ts, 0, 0))
abstract foo(): unknown;
>foo : Symbol(Base.foo, Decl(override10.ts, 0, 21))
abstract bar(): void;
>bar : Symbol(Base.bar, Decl(override10.ts, 1, 28))
}
// No errors:
abstract class Sub extends Base {
>Sub : Symbol(Sub, Decl(override10.ts, 3, 1))
>Base : Symbol(Base, Decl(override10.ts, 0, 0))
override abstract foo(): number;
>foo : Symbol(Sub.foo, Decl(override10.ts, 6, 33))
bar() { }
>bar : Symbol(Sub.bar, Decl(override10.ts, 7, 36))
}
@@ -0,0 +1,22 @@
=== tests/cases/conformance/override/override10.ts ===
abstract class Base {
>Base : Base
abstract foo(): unknown;
>foo : () => unknown
abstract bar(): void;
>bar : () => void
}
// No errors:
abstract class Sub extends Base {
>Sub : Sub
>Base : Base
override abstract foo(): number;
>foo : () => number
bar() { }
>bar : () => void
}
@@ -0,0 +1,16 @@
tests/cases/conformance/override/override11.ts(6,18): error TS1090: 'override' modifier cannot appear on a parameter.
==== tests/cases/conformance/override/override11.ts (1 errors) ====
class Base {
foo = 1;
}
class Sub extends Base {
constructor (override public foo: number) {
~~~~~~~~
!!! error TS1090: 'override' modifier cannot appear on a parameter.
super();
}
}
+43
View File
@@ -0,0 +1,43 @@
//// [override11.ts]
class Base {
foo = 1;
}
class Sub extends Base {
constructor (override public foo: number) {
super();
}
}
//// [override11.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Base = /** @class */ (function () {
function Base() {
this.foo = 1;
}
return Base;
}());
var Sub = /** @class */ (function (_super) {
__extends(Sub, _super);
function Sub(foo) {
var _this = _super.call(this) || this;
_this.foo = foo;
return _this;
}
return Sub;
}(Base));
@@ -0,0 +1,20 @@
=== tests/cases/conformance/override/override11.ts ===
class Base {
>Base : Symbol(Base, Decl(override11.ts, 0, 0))
foo = 1;
>foo : Symbol(Base.foo, Decl(override11.ts, 0, 12))
}
class Sub extends Base {
>Sub : Symbol(Sub, Decl(override11.ts, 2, 1))
>Base : Symbol(Base, Decl(override11.ts, 0, 0))
constructor (override public foo: number) {
>foo : Symbol(Sub.foo, Decl(override11.ts, 5, 17))
super();
>super : Symbol(Base, Decl(override11.ts, 0, 0))
}
}
@@ -0,0 +1,22 @@
=== tests/cases/conformance/override/override11.ts ===
class Base {
>Base : Base
foo = 1;
>foo : number
>1 : 1
}
class Sub extends Base {
>Sub : Sub
>Base : Base
constructor (override public foo: number) {
>foo : number
super();
>super() : void
>super : typeof Base
}
}
@@ -0,0 +1,35 @@
tests/cases/conformance/override/override2.ts(13,14): error TS4116: This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class 'AB'.
tests/cases/conformance/override/override2.ts(18,14): error TS4116: This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class 'AB'.
==== tests/cases/conformance/override/override2.ts (2 errors) ====
abstract class AB {
abstract foo(v: string): void;
abstract bar(v: string): void;
abstract baz(v: string): void;
}
abstract class AD1 extends AB {
}
abstract class AD2 extends AB {
abstract foo(v: ''): void // need override?
~~~
!!! error TS4116: This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class 'AB'.
}
abstract class AD3 extends AB {
override foo(v: ''): void { } // need override?
abstract bar(): void;
~~~
!!! error TS4116: This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class 'AB'.
baz(): void { }
}
class D4 extends AB {
override foo(v: ''): void {}
override bar(v: ''): void {}
baz(): void { }
}
+105
View File
@@ -0,0 +1,105 @@
//// [override2.ts]
abstract class AB {
abstract foo(v: string): void;
abstract bar(v: string): void;
abstract baz(v: string): void;
}
abstract class AD1 extends AB {
}
abstract class AD2 extends AB {
abstract foo(v: ''): void // need override?
}
abstract class AD3 extends AB {
override foo(v: ''): void { } // need override?
abstract bar(): void;
baz(): void { }
}
class D4 extends AB {
override foo(v: ''): void {}
override bar(v: ''): void {}
baz(): void { }
}
//// [override2.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AB = /** @class */ (function () {
function AB() {
}
return AB;
}());
var AD1 = /** @class */ (function (_super) {
__extends(AD1, _super);
function AD1() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AD1;
}(AB));
var AD2 = /** @class */ (function (_super) {
__extends(AD2, _super);
function AD2() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AD2;
}(AB));
var AD3 = /** @class */ (function (_super) {
__extends(AD3, _super);
function AD3() {
return _super !== null && _super.apply(this, arguments) || this;
}
AD3.prototype.foo = function (v) { }; // need override?
AD3.prototype.baz = function () { };
return AD3;
}(AB));
var D4 = /** @class */ (function (_super) {
__extends(D4, _super);
function D4() {
return _super !== null && _super.apply(this, arguments) || this;
}
D4.prototype.foo = function (v) { };
D4.prototype.bar = function (v) { };
D4.prototype.baz = function () { };
return D4;
}(AB));
//// [override2.d.ts]
declare abstract class AB {
abstract foo(v: string): void;
abstract bar(v: string): void;
abstract baz(v: string): void;
}
declare abstract class AD1 extends AB {
}
declare abstract class AD2 extends AB {
abstract foo(v: ''): void;
}
declare abstract class AD3 extends AB {
foo(v: ''): void;
abstract bar(): void;
baz(): void;
}
declare class D4 extends AB {
foo(v: ''): void;
bar(v: ''): void;
baz(): void;
}
@@ -0,0 +1,62 @@
=== tests/cases/conformance/override/override2.ts ===
abstract class AB {
>AB : Symbol(AB, Decl(override2.ts, 0, 0))
abstract foo(v: string): void;
>foo : Symbol(AB.foo, Decl(override2.ts, 0, 19))
>v : Symbol(v, Decl(override2.ts, 1, 17))
abstract bar(v: string): void;
>bar : Symbol(AB.bar, Decl(override2.ts, 1, 34))
>v : Symbol(v, Decl(override2.ts, 3, 17))
abstract baz(v: string): void;
>baz : Symbol(AB.baz, Decl(override2.ts, 3, 34))
>v : Symbol(v, Decl(override2.ts, 4, 17))
}
abstract class AD1 extends AB {
>AD1 : Symbol(AD1, Decl(override2.ts, 5, 1))
>AB : Symbol(AB, Decl(override2.ts, 0, 0))
}
abstract class AD2 extends AB {
>AD2 : Symbol(AD2, Decl(override2.ts, 9, 1))
>AB : Symbol(AB, Decl(override2.ts, 0, 0))
abstract foo(v: ''): void // need override?
>foo : Symbol(AD2.foo, Decl(override2.ts, 11, 31))
>v : Symbol(v, Decl(override2.ts, 12, 17))
}
abstract class AD3 extends AB {
>AD3 : Symbol(AD3, Decl(override2.ts, 13, 1))
>AB : Symbol(AB, Decl(override2.ts, 0, 0))
override foo(v: ''): void { } // need override?
>foo : Symbol(AD3.foo, Decl(override2.ts, 15, 31))
>v : Symbol(v, Decl(override2.ts, 16, 17))
abstract bar(): void;
>bar : Symbol(AD3.bar, Decl(override2.ts, 16, 33))
baz(): void { }
>baz : Symbol(AD3.baz, Decl(override2.ts, 17, 25))
}
class D4 extends AB {
>D4 : Symbol(D4, Decl(override2.ts, 19, 1))
>AB : Symbol(AB, Decl(override2.ts, 0, 0))
override foo(v: ''): void {}
>foo : Symbol(D4.foo, Decl(override2.ts, 21, 21))
>v : Symbol(v, Decl(override2.ts, 22, 17))
override bar(v: ''): void {}
>bar : Symbol(D4.bar, Decl(override2.ts, 22, 32))
>v : Symbol(v, Decl(override2.ts, 23, 17))
baz(): void { }
>baz : Symbol(D4.baz, Decl(override2.ts, 23, 32))
}
+62
View File
@@ -0,0 +1,62 @@
=== tests/cases/conformance/override/override2.ts ===
abstract class AB {
>AB : AB
abstract foo(v: string): void;
>foo : (v: string) => void
>v : string
abstract bar(v: string): void;
>bar : (v: string) => void
>v : string
abstract baz(v: string): void;
>baz : (v: string) => void
>v : string
}
abstract class AD1 extends AB {
>AD1 : AD1
>AB : AB
}
abstract class AD2 extends AB {
>AD2 : AD2
>AB : AB
abstract foo(v: ''): void // need override?
>foo : (v: '') => void
>v : ""
}
abstract class AD3 extends AB {
>AD3 : AD3
>AB : AB
override foo(v: ''): void { } // need override?
>foo : (v: '') => void
>v : ""
abstract bar(): void;
>bar : () => void
baz(): void { }
>baz : () => void
}
class D4 extends AB {
>D4 : D4
>AB : AB
override foo(v: ''): void {}
>foo : (v: '') => void
>v : ""
override bar(v: ''): void {}
>bar : (v: '') => void
>v : ""
baz(): void { }
>baz : () => void
}
@@ -0,0 +1,31 @@
tests/cases/conformance/override/override3.ts(22,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'D'.
==== tests/cases/conformance/override/override3.ts (1 errors) ====
declare class B {
foo(): void
bar(): void
}
declare class D extends B {
foo (): void;
override bar (): void;
}
class DB extends B {
override foo(): void {}
override bar(): void {}
}
class DD extends D {
override foo(): void {}
override bar(): void {}
}
class EB extends D {
foo(): void {}
~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'D'.
override bar(): void {}
}
+93
View File
@@ -0,0 +1,93 @@
//// [override3.ts]
declare class B {
foo(): void
bar(): void
}
declare class D extends B {
foo (): void;
override bar (): void;
}
class DB extends B {
override foo(): void {}
override bar(): void {}
}
class DD extends D {
override foo(): void {}
override bar(): void {}
}
class EB extends D {
foo(): void {}
override bar(): void {}
}
//// [override3.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var DB = /** @class */ (function (_super) {
__extends(DB, _super);
function DB() {
return _super !== null && _super.apply(this, arguments) || this;
}
DB.prototype.foo = function () { };
DB.prototype.bar = function () { };
return DB;
}(B));
var DD = /** @class */ (function (_super) {
__extends(DD, _super);
function DD() {
return _super !== null && _super.apply(this, arguments) || this;
}
DD.prototype.foo = function () { };
DD.prototype.bar = function () { };
return DD;
}(D));
var EB = /** @class */ (function (_super) {
__extends(EB, _super);
function EB() {
return _super !== null && _super.apply(this, arguments) || this;
}
EB.prototype.foo = function () { };
EB.prototype.bar = function () { };
return EB;
}(D));
//// [override3.d.ts]
declare class B {
foo(): void;
bar(): void;
}
declare class D extends B {
foo(): void;
bar(): void;
}
declare class DB extends B {
foo(): void;
bar(): void;
}
declare class DD extends D {
foo(): void;
bar(): void;
}
declare class EB extends D {
foo(): void;
bar(): void;
}
@@ -0,0 +1,55 @@
=== tests/cases/conformance/override/override3.ts ===
declare class B {
>B : Symbol(B, Decl(override3.ts, 0, 0))
foo(): void
>foo : Symbol(B.foo, Decl(override3.ts, 0, 17))
bar(): void
>bar : Symbol(B.bar, Decl(override3.ts, 1, 15))
}
declare class D extends B {
>D : Symbol(D, Decl(override3.ts, 3, 1))
>B : Symbol(B, Decl(override3.ts, 0, 0))
foo (): void;
>foo : Symbol(D.foo, Decl(override3.ts, 5, 27))
override bar (): void;
>bar : Symbol(D.bar, Decl(override3.ts, 6, 17))
}
class DB extends B {
>DB : Symbol(DB, Decl(override3.ts, 8, 1))
>B : Symbol(B, Decl(override3.ts, 0, 0))
override foo(): void {}
>foo : Symbol(DB.foo, Decl(override3.ts, 10, 20))
override bar(): void {}
>bar : Symbol(DB.bar, Decl(override3.ts, 11, 27))
}
class DD extends D {
>DD : Symbol(DD, Decl(override3.ts, 13, 1))
>D : Symbol(D, Decl(override3.ts, 3, 1))
override foo(): void {}
>foo : Symbol(DD.foo, Decl(override3.ts, 15, 20))
override bar(): void {}
>bar : Symbol(DD.bar, Decl(override3.ts, 16, 27))
}
class EB extends D {
>EB : Symbol(EB, Decl(override3.ts, 18, 1))
>D : Symbol(D, Decl(override3.ts, 3, 1))
foo(): void {}
>foo : Symbol(EB.foo, Decl(override3.ts, 20, 20))
override bar(): void {}
>bar : Symbol(EB.bar, Decl(override3.ts, 21, 18))
}
+55
View File
@@ -0,0 +1,55 @@
=== tests/cases/conformance/override/override3.ts ===
declare class B {
>B : B
foo(): void
>foo : () => void
bar(): void
>bar : () => void
}
declare class D extends B {
>D : D
>B : B
foo (): void;
>foo : () => void
override bar (): void;
>bar : () => void
}
class DB extends B {
>DB : DB
>B : B
override foo(): void {}
>foo : () => void
override bar(): void {}
>bar : () => void
}
class DD extends D {
>DD : DD
>D : D
override foo(): void {}
>foo : () => void
override bar(): void {}
>bar : () => void
}
class EB extends D {
>EB : EB
>D : D
foo(): void {}
>foo : () => void
override bar(): void {}
>bar : () => void
}
@@ -0,0 +1,39 @@
tests/cases/conformance/override/override4.ts(11,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override4.ts(13,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override4.ts(17,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override4.ts(23,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
==== tests/cases/conformance/override/override4.ts (4 errors) ====
class B {
p1: number = 1;
p2: number = 1;
p3: () => void;
p4: () => void;
foo (v: string) {}
fooo (v: string) {}
}
class D extends B {
p1: number = 2;
~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
override p2: number = 3;
p3: () => void;
~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
override p4: () => void;
override foo (v: string) {}
fooo (v: string) {}
~~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
}
class DD extends B {
override foo: () => void
fooo: () => void;
~~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
}
+93
View File
@@ -0,0 +1,93 @@
//// [override4.ts]
class B {
p1: number = 1;
p2: number = 1;
p3: () => void;
p4: () => void;
foo (v: string) {}
fooo (v: string) {}
}
class D extends B {
p1: number = 2;
override p2: number = 3;
p3: () => void;
override p4: () => void;
override foo (v: string) {}
fooo (v: string) {}
}
class DD extends B {
override foo: () => void
fooo: () => void;
}
//// [override4.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B() {
this.p1 = 1;
this.p2 = 1;
}
B.prototype.foo = function (v) { };
B.prototype.fooo = function (v) { };
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.p1 = 2;
_this.p2 = 3;
return _this;
}
D.prototype.foo = function (v) { };
D.prototype.fooo = function (v) { };
return D;
}(B));
var DD = /** @class */ (function (_super) {
__extends(DD, _super);
function DD() {
return _super !== null && _super.apply(this, arguments) || this;
}
return DD;
}(B));
//// [override4.d.ts]
declare class B {
p1: number;
p2: number;
p3: () => void;
p4: () => void;
foo(v: string): void;
fooo(v: string): void;
}
declare class D extends B {
p1: number;
p2: number;
p3: () => void;
p4: () => void;
foo(v: string): void;
fooo(v: string): void;
}
declare class DD extends B {
foo: () => void;
fooo: () => void;
}
@@ -0,0 +1,61 @@
=== tests/cases/conformance/override/override4.ts ===
class B {
>B : Symbol(B, Decl(override4.ts, 0, 0))
p1: number = 1;
>p1 : Symbol(B.p1, Decl(override4.ts, 0, 9))
p2: number = 1;
>p2 : Symbol(B.p2, Decl(override4.ts, 1, 19))
p3: () => void;
>p3 : Symbol(B.p3, Decl(override4.ts, 2, 19))
p4: () => void;
>p4 : Symbol(B.p4, Decl(override4.ts, 3, 19))
foo (v: string) {}
>foo : Symbol(B.foo, Decl(override4.ts, 4, 19))
>v : Symbol(v, Decl(override4.ts, 5, 9))
fooo (v: string) {}
>fooo : Symbol(B.fooo, Decl(override4.ts, 5, 22))
>v : Symbol(v, Decl(override4.ts, 6, 10))
}
class D extends B {
>D : Symbol(D, Decl(override4.ts, 7, 1))
>B : Symbol(B, Decl(override4.ts, 0, 0))
p1: number = 2;
>p1 : Symbol(D.p1, Decl(override4.ts, 9, 19))
override p2: number = 3;
>p2 : Symbol(D.p2, Decl(override4.ts, 10, 19))
p3: () => void;
>p3 : Symbol(D.p3, Decl(override4.ts, 11, 28))
override p4: () => void;
>p4 : Symbol(D.p4, Decl(override4.ts, 12, 19))
override foo (v: string) {}
>foo : Symbol(D.foo, Decl(override4.ts, 13, 28))
>v : Symbol(v, Decl(override4.ts, 14, 18))
fooo (v: string) {}
>fooo : Symbol(D.fooo, Decl(override4.ts, 14, 31))
>v : Symbol(v, Decl(override4.ts, 16, 10))
}
class DD extends B {
>DD : Symbol(DD, Decl(override4.ts, 18, 1))
>B : Symbol(B, Decl(override4.ts, 0, 0))
override foo: () => void
>foo : Symbol(DD.foo, Decl(override4.ts, 20, 20))
fooo: () => void;
>fooo : Symbol(DD.fooo, Decl(override4.ts, 21, 28))
}
+65
View File
@@ -0,0 +1,65 @@
=== tests/cases/conformance/override/override4.ts ===
class B {
>B : B
p1: number = 1;
>p1 : number
>1 : 1
p2: number = 1;
>p2 : number
>1 : 1
p3: () => void;
>p3 : () => void
p4: () => void;
>p4 : () => void
foo (v: string) {}
>foo : (v: string) => void
>v : string
fooo (v: string) {}
>fooo : (v: string) => void
>v : string
}
class D extends B {
>D : D
>B : B
p1: number = 2;
>p1 : number
>2 : 2
override p2: number = 3;
>p2 : number
>3 : 3
p3: () => void;
>p3 : () => void
override p4: () => void;
>p4 : () => void
override foo (v: string) {}
>foo : (v: string) => void
>v : string
fooo (v: string) {}
>fooo : (v: string) => void
>v : string
}
class DD extends B {
>DD : DD
>B : B
override foo: () => void
>foo : () => void
fooo: () => void;
>fooo : () => void
}
@@ -0,0 +1,83 @@
tests/cases/conformance/override/override5.ts(12,13): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override5.ts(14,14): error TS1040: 'override' modifier cannot be used in an ambient context.
tests/cases/conformance/override/override5.ts(20,14): error TS1243: 'static' modifier cannot be used with 'override' modifier.
tests/cases/conformance/override/override5.ts(22,14): error TS1030: 'override' modifier already seen.
tests/cases/conformance/override/override5.ts(25,14): error TS1029: 'public' modifier must precede 'override' modifier.
tests/cases/conformance/override/override5.ts(27,5): error TS1089: 'override' modifier cannot appear on a constructor declaration.
tests/cases/conformance/override/override5.ts(44,23): error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
tests/cases/conformance/override/override5.ts(45,23): error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
==== tests/cases/conformance/override/override5.ts (8 errors) ====
class B {
p1: number = 1;
p2: number = 2;
p3: number = 3;
p4: number = 4;
oop: number;
pp: number;
op: number;
}
class D extends B{
declare p1: number
~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
override declare p2: number;
~~~~~~~
!!! error TS1040: 'override' modifier cannot be used in an ambient context.
readonly override p3: number;
override readonly p4: number;
override static sp: number;
~~~~~~
!!! error TS1243: 'static' modifier cannot be used with 'override' modifier.
override override oop: number;
~~~~~~~~
!!! error TS1030: 'override' modifier already seen.
public override pp: number;
override public op: number;
~~~~~~
!!! error TS1029: 'public' modifier must precede 'override' modifier.
override constructor () {
~~~~~~~~
!!! error TS1089: 'override' modifier cannot appear on a constructor declaration.
super();
}
}
abstract class AB {
abstract f (): void;
abstract b (): void;
}
abstract class AD extends AB {
override abstract f(): void;
abstract override b(): void;
}
abstract class AND {
override abstract f(): void;
~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
abstract override b(): void;
~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
}
class ADD extends AD {
f(): void {
}
override b(): void {
}
}
+157
View File
@@ -0,0 +1,157 @@
//// [override5.ts]
class B {
p1: number = 1;
p2: number = 2;
p3: number = 3;
p4: number = 4;
oop: number;
pp: number;
op: number;
}
class D extends B{
declare p1: number
override declare p2: number;
readonly override p3: number;
override readonly p4: number;
override static sp: number;
override override oop: number;
public override pp: number;
override public op: number;
override constructor () {
super();
}
}
abstract class AB {
abstract f (): void;
abstract b (): void;
}
abstract class AD extends AB {
override abstract f(): void;
abstract override b(): void;
}
abstract class AND {
override abstract f(): void;
abstract override b(): void;
}
class ADD extends AD {
f(): void {
}
override b(): void {
}
}
//// [override5.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B() {
this.p1 = 1;
this.p2 = 2;
this.p3 = 3;
this.p4 = 4;
}
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D() {
return _super.call(this) || this;
}
return D;
}(B));
var AB = /** @class */ (function () {
function AB() {
}
return AB;
}());
var AD = /** @class */ (function (_super) {
__extends(AD, _super);
function AD() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AD;
}(AB));
var AND = /** @class */ (function () {
function AND() {
}
return AND;
}());
var ADD = /** @class */ (function (_super) {
__extends(ADD, _super);
function ADD() {
return _super !== null && _super.apply(this, arguments) || this;
}
ADD.prototype.f = function () {
};
ADD.prototype.b = function () {
};
return ADD;
}(AD));
//// [override5.d.ts]
declare class B {
p1: number;
p2: number;
p3: number;
p4: number;
oop: number;
pp: number;
op: number;
}
declare class D extends B {
p1: number;
p2: number;
readonly p3: number;
readonly p4: number;
static sp: number;
oop: number;
pp: number;
op: number;
constructor();
}
declare abstract class AB {
abstract f(): void;
abstract b(): void;
}
declare abstract class AD extends AB {
abstract f(): void;
abstract b(): void;
}
declare abstract class AND {
abstract f(): void;
abstract b(): void;
}
declare class ADD extends AD {
f(): void;
b(): void;
}
+106
View File
@@ -0,0 +1,106 @@
=== tests/cases/conformance/override/override5.ts ===
class B {
>B : Symbol(B, Decl(override5.ts, 0, 0))
p1: number = 1;
>p1 : Symbol(B.p1, Decl(override5.ts, 0, 9))
p2: number = 2;
>p2 : Symbol(B.p2, Decl(override5.ts, 1, 19))
p3: number = 3;
>p3 : Symbol(B.p3, Decl(override5.ts, 2, 19))
p4: number = 4;
>p4 : Symbol(B.p4, Decl(override5.ts, 3, 19))
oop: number;
>oop : Symbol(B.oop, Decl(override5.ts, 4, 19))
pp: number;
>pp : Symbol(B.pp, Decl(override5.ts, 5, 16))
op: number;
>op : Symbol(B.op, Decl(override5.ts, 6, 15))
}
class D extends B{
>D : Symbol(D, Decl(override5.ts, 8, 1))
>B : Symbol(B, Decl(override5.ts, 0, 0))
declare p1: number
>p1 : Symbol(D.p1, Decl(override5.ts, 10, 18))
override declare p2: number;
>p2 : Symbol(D.p2, Decl(override5.ts, 11, 22))
readonly override p3: number;
>p3 : Symbol(D.p3, Decl(override5.ts, 13, 32))
override readonly p4: number;
>p4 : Symbol(D.p4, Decl(override5.ts, 15, 33))
override static sp: number;
>sp : Symbol(D.sp, Decl(override5.ts, 17, 33))
override override oop: number;
>oop : Symbol(D.oop, Decl(override5.ts, 19, 31))
public override pp: number;
>pp : Symbol(D.pp, Decl(override5.ts, 21, 34))
override public op: number;
>op : Symbol(D.op, Decl(override5.ts, 23, 31))
override constructor () {
super();
>super : Symbol(B, Decl(override5.ts, 0, 0))
}
}
abstract class AB {
>AB : Symbol(AB, Decl(override5.ts, 29, 1))
abstract f (): void;
>f : Symbol(AB.f, Decl(override5.ts, 32, 19))
abstract b (): void;
>b : Symbol(AB.b, Decl(override5.ts, 33, 24))
}
abstract class AD extends AB {
>AD : Symbol(AD, Decl(override5.ts, 35, 1))
>AB : Symbol(AB, Decl(override5.ts, 29, 1))
override abstract f(): void;
>f : Symbol(AD.f, Decl(override5.ts, 37, 30))
abstract override b(): void;
>b : Symbol(AD.b, Decl(override5.ts, 38, 32))
}
abstract class AND {
>AND : Symbol(AND, Decl(override5.ts, 40, 1))
override abstract f(): void;
>f : Symbol(AND.f, Decl(override5.ts, 42, 20))
abstract override b(): void;
>b : Symbol(AND.b, Decl(override5.ts, 43, 32))
}
class ADD extends AD {
>ADD : Symbol(ADD, Decl(override5.ts, 45, 1))
>AD : Symbol(AD, Decl(override5.ts, 35, 1))
f(): void {
>f : Symbol(ADD.f, Decl(override5.ts, 47, 22))
}
override b(): void {
>b : Symbol(ADD.b, Decl(override5.ts, 50, 5))
}
}
+111
View File
@@ -0,0 +1,111 @@
=== tests/cases/conformance/override/override5.ts ===
class B {
>B : B
p1: number = 1;
>p1 : number
>1 : 1
p2: number = 2;
>p2 : number
>2 : 2
p3: number = 3;
>p3 : number
>3 : 3
p4: number = 4;
>p4 : number
>4 : 4
oop: number;
>oop : number
pp: number;
>pp : number
op: number;
>op : number
}
class D extends B{
>D : D
>B : B
declare p1: number
>p1 : number
override declare p2: number;
>p2 : number
readonly override p3: number;
>p3 : number
override readonly p4: number;
>p4 : number
override static sp: number;
>sp : number
override override oop: number;
>oop : number
public override pp: number;
>pp : number
override public op: number;
>op : number
override constructor () {
super();
>super() : void
>super : typeof B
}
}
abstract class AB {
>AB : AB
abstract f (): void;
>f : () => void
abstract b (): void;
>b : () => void
}
abstract class AD extends AB {
>AD : AD
>AB : AB
override abstract f(): void;
>f : () => void
abstract override b(): void;
>b : () => void
}
abstract class AND {
>AND : AND
override abstract f(): void;
>f : () => void
abstract override b(): void;
>b : () => void
}
class ADD extends AD {
>ADD : ADD
>AD : AD
f(): void {
>f : () => void
}
override b(): void {
>b : () => void
}
}
@@ -0,0 +1,26 @@
tests/cases/conformance/override/override6.ts(9,12): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/override6.ts(10,17): error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'B'.
tests/cases/conformance/override/override6.ts(10,37): error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'B'.
==== tests/cases/conformance/override/override6.ts (3 errors) ====
class B {
public baz: number = 1;
constructor(public foo: string, public bar: number) {
}
}
class D extends B {
public bar: number = 1
~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
constructor(public foo: string, public baz: number) {
~~~~~~~~~~~~~~~~~~
!!! error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'B'.
~~~~~~~~~~~~~~~~~~
!!! error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'B'.
super(foo, 42)
}
}
+66
View File
@@ -0,0 +1,66 @@
//// [override6.ts]
class B {
public baz: number = 1;
constructor(public foo: string, public bar: number) {
}
}
class D extends B {
public bar: number = 1
constructor(public foo: string, public baz: number) {
super(foo, 42)
}
}
//// [override6.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B(foo, bar) {
this.foo = foo;
this.bar = bar;
this.baz = 1;
}
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D(foo, baz) {
var _this = _super.call(this, foo, 42) || this;
_this.foo = foo;
_this.baz = baz;
_this.bar = 1;
return _this;
}
return D;
}(B));
//// [override6.d.ts]
declare class B {
foo: string;
bar: number;
baz: number;
constructor(foo: string, bar: number);
}
declare class D extends B {
foo: string;
baz: number;
bar: number;
constructor(foo: string, baz: number);
}
@@ -0,0 +1,31 @@
=== tests/cases/conformance/override/override6.ts ===
class B {
>B : Symbol(B, Decl(override6.ts, 0, 0))
public baz: number = 1;
>baz : Symbol(B.baz, Decl(override6.ts, 0, 9))
constructor(public foo: string, public bar: number) {
>foo : Symbol(B.foo, Decl(override6.ts, 2, 16))
>bar : Symbol(B.bar, Decl(override6.ts, 2, 35))
}
}
class D extends B {
>D : Symbol(D, Decl(override6.ts, 5, 1))
>B : Symbol(B, Decl(override6.ts, 0, 0))
public bar: number = 1
>bar : Symbol(D.bar, Decl(override6.ts, 7, 19))
constructor(public foo: string, public baz: number) {
>foo : Symbol(D.foo, Decl(override6.ts, 9, 16))
>baz : Symbol(D.baz, Decl(override6.ts, 9, 35))
super(foo, 42)
>super : Symbol(B, Decl(override6.ts, 0, 0))
>foo : Symbol(foo, Decl(override6.ts, 9, 16))
}
}
+35
View File
@@ -0,0 +1,35 @@
=== tests/cases/conformance/override/override6.ts ===
class B {
>B : B
public baz: number = 1;
>baz : number
>1 : 1
constructor(public foo: string, public bar: number) {
>foo : string
>bar : number
}
}
class D extends B {
>D : D
>B : B
public bar: number = 1
>bar : number
>1 : 1
constructor(public foo: string, public baz: number) {
>foo : string
>baz : number
super(foo, 42)
>super(foo, 42) : void
>super : typeof B
>foo : string
>42 : 42
}
}
@@ -0,0 +1,74 @@
tests/cases/conformance/override/override7.ts(19,14): error TS1030: 'override' modifier already seen.
tests/cases/conformance/override/override7.ts(19,23): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
tests/cases/conformance/override/override7.ts(21,21): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
tests/cases/conformance/override/override7.ts(22,21): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
tests/cases/conformance/override/override7.ts(41,23): error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
tests/cases/conformance/override/override7.ts(42,23): error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
==== tests/cases/conformance/override/override7.ts (6 errors) ====
class B {
p1: number = 1;
p2: number = 2;
p3: number = 3;
p4: number = 4;
}
class D extends B{
declare p1: number
override declare p2: number;
readonly override p3: number;
override readonly p4: number;
override static sp: number;
override override oop: number;
~~~~~~~~
!!! error TS1030: 'override' modifier already seen.
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
public override pp: number;
~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
override public op: number;
~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
override constructor () {
super();
}
}
abstract class AB {
abstract f (): void;
abstract b (): void;
}
abstract class AD extends AB {
override abstract f(): void;
abstract override b(): void;
}
abstract class AND {
override abstract f(): void;
~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
abstract override b(): void;
~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'AND' does not extend another class.
}
class ADD extends AD {
override f(): void {
}
override b(): void {
}
}
+151
View File
@@ -0,0 +1,151 @@
//// [override7.ts]
class B {
p1: number = 1;
p2: number = 2;
p3: number = 3;
p4: number = 4;
}
class D extends B{
declare p1: number
override declare p2: number;
readonly override p3: number;
override readonly p4: number;
override static sp: number;
override override oop: number;
public override pp: number;
override public op: number;
override constructor () {
super();
}
}
abstract class AB {
abstract f (): void;
abstract b (): void;
}
abstract class AD extends AB {
override abstract f(): void;
abstract override b(): void;
}
abstract class AND {
override abstract f(): void;
abstract override b(): void;
}
class ADD extends AD {
override f(): void {
}
override b(): void {
}
}
//// [override7.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B() {
this.p1 = 1;
this.p2 = 2;
this.p3 = 3;
this.p4 = 4;
}
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D() {
return _super.call(this) || this;
}
return D;
}(B));
var AB = /** @class */ (function () {
function AB() {
}
return AB;
}());
var AD = /** @class */ (function (_super) {
__extends(AD, _super);
function AD() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AD;
}(AB));
var AND = /** @class */ (function () {
function AND() {
}
return AND;
}());
var ADD = /** @class */ (function (_super) {
__extends(ADD, _super);
function ADD() {
return _super !== null && _super.apply(this, arguments) || this;
}
ADD.prototype.f = function () {
};
ADD.prototype.b = function () {
};
return ADD;
}(AD));
//// [override7.d.ts]
declare class B {
p1: number;
p2: number;
p3: number;
p4: number;
}
declare class D extends B {
p1: number;
p2: number;
readonly p3: number;
readonly p4: number;
static sp: number;
oop: number;
pp: number;
op: number;
constructor();
}
declare abstract class AB {
abstract f(): void;
abstract b(): void;
}
declare abstract class AD extends AB {
abstract f(): void;
abstract b(): void;
}
declare abstract class AND {
abstract f(): void;
abstract b(): void;
}
declare class ADD extends AD {
f(): void;
b(): void;
}
@@ -0,0 +1,97 @@
=== tests/cases/conformance/override/override7.ts ===
class B {
>B : Symbol(B, Decl(override7.ts, 0, 0))
p1: number = 1;
>p1 : Symbol(B.p1, Decl(override7.ts, 0, 9))
p2: number = 2;
>p2 : Symbol(B.p2, Decl(override7.ts, 1, 19))
p3: number = 3;
>p3 : Symbol(B.p3, Decl(override7.ts, 2, 19))
p4: number = 4;
>p4 : Symbol(B.p4, Decl(override7.ts, 3, 19))
}
class D extends B{
>D : Symbol(D, Decl(override7.ts, 5, 1))
>B : Symbol(B, Decl(override7.ts, 0, 0))
declare p1: number
>p1 : Symbol(D.p1, Decl(override7.ts, 7, 18))
override declare p2: number;
>p2 : Symbol(D.p2, Decl(override7.ts, 8, 22))
readonly override p3: number;
>p3 : Symbol(D.p3, Decl(override7.ts, 10, 32))
override readonly p4: number;
>p4 : Symbol(D.p4, Decl(override7.ts, 12, 33))
override static sp: number;
>sp : Symbol(D.sp, Decl(override7.ts, 14, 33))
override override oop: number;
>oop : Symbol(D.oop, Decl(override7.ts, 16, 31))
public override pp: number;
>pp : Symbol(D.pp, Decl(override7.ts, 18, 34))
override public op: number;
>op : Symbol(D.op, Decl(override7.ts, 20, 31))
override constructor () {
super();
>super : Symbol(B, Decl(override7.ts, 0, 0))
}
}
abstract class AB {
>AB : Symbol(AB, Decl(override7.ts, 26, 1))
abstract f (): void;
>f : Symbol(AB.f, Decl(override7.ts, 29, 19))
abstract b (): void;
>b : Symbol(AB.b, Decl(override7.ts, 30, 24))
}
abstract class AD extends AB {
>AD : Symbol(AD, Decl(override7.ts, 32, 1))
>AB : Symbol(AB, Decl(override7.ts, 26, 1))
override abstract f(): void;
>f : Symbol(AD.f, Decl(override7.ts, 34, 30))
abstract override b(): void;
>b : Symbol(AD.b, Decl(override7.ts, 35, 32))
}
abstract class AND {
>AND : Symbol(AND, Decl(override7.ts, 37, 1))
override abstract f(): void;
>f : Symbol(AND.f, Decl(override7.ts, 39, 20))
abstract override b(): void;
>b : Symbol(AND.b, Decl(override7.ts, 40, 32))
}
class ADD extends AD {
>ADD : Symbol(ADD, Decl(override7.ts, 42, 1))
>AD : Symbol(AD, Decl(override7.ts, 32, 1))
override f(): void {
>f : Symbol(ADD.f, Decl(override7.ts, 44, 22))
}
override b(): void {
>b : Symbol(ADD.b, Decl(override7.ts, 47, 5))
}
}
+102
View File
@@ -0,0 +1,102 @@
=== tests/cases/conformance/override/override7.ts ===
class B {
>B : B
p1: number = 1;
>p1 : number
>1 : 1
p2: number = 2;
>p2 : number
>2 : 2
p3: number = 3;
>p3 : number
>3 : 3
p4: number = 4;
>p4 : number
>4 : 4
}
class D extends B{
>D : D
>B : B
declare p1: number
>p1 : number
override declare p2: number;
>p2 : number
readonly override p3: number;
>p3 : number
override readonly p4: number;
>p4 : number
override static sp: number;
>sp : number
override override oop: number;
>oop : number
public override pp: number;
>pp : number
override public op: number;
>op : number
override constructor () {
super();
>super() : void
>super : typeof B
}
}
abstract class AB {
>AB : AB
abstract f (): void;
>f : () => void
abstract b (): void;
>b : () => void
}
abstract class AD extends AB {
>AD : AD
>AB : AB
override abstract f(): void;
>f : () => void
abstract override b(): void;
>b : () => void
}
abstract class AND {
>AND : AND
override abstract f(): void;
>f : () => void
abstract override b(): void;
>b : () => void
}
class ADD extends AD {
>ADD : ADD
>AD : AD
override f(): void {
>f : () => void
}
override b(): void {
>b : () => void
}
}
@@ -0,0 +1,42 @@
tests/cases/conformance/override/override8.ts(6,17): error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'B'.
tests/cases/conformance/override/override8.ts(18,17): error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'BB'.
tests/cases/conformance/override/override8.ts(24,12): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'BB'.
==== tests/cases/conformance/override/override8.ts (3 errors) ====
class B {
a: string
}
class D extends B {
constructor(public a: string, public b: string) {
~~~~~~~~~~~~~~~~
!!! error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'B'.
super();
}
}
class BB {
constructor(public a: string) {
}
}
class DD extends BB {
constructor(public a: string) {
~~~~~~~~~~~~~~~~
!!! error TS4115: This parameter property must be rewritten as a property declaration with an 'override' modifier because it overrides a member in base class 'BB'.
super(a)
}
}
class DDD extends BB {
public a: string;
~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'BB'.
constructor(a: string) {
super(a)
this.a = a
}
}
+110
View File
@@ -0,0 +1,110 @@
//// [override8.ts]
class B {
a: string
}
class D extends B {
constructor(public a: string, public b: string) {
super();
}
}
class BB {
constructor(public a: string) {
}
}
class DD extends BB {
constructor(public a: string) {
super(a)
}
}
class DDD extends BB {
public a: string;
constructor(a: string) {
super(a)
this.a = a
}
}
//// [override8.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B() {
}
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D(a, b) {
var _this = _super.call(this) || this;
_this.a = a;
_this.b = b;
return _this;
}
return D;
}(B));
var BB = /** @class */ (function () {
function BB(a) {
this.a = a;
}
return BB;
}());
var DD = /** @class */ (function (_super) {
__extends(DD, _super);
function DD(a) {
var _this = _super.call(this, a) || this;
_this.a = a;
return _this;
}
return DD;
}(BB));
var DDD = /** @class */ (function (_super) {
__extends(DDD, _super);
function DDD(a) {
var _this = _super.call(this, a) || this;
_this.a = a;
return _this;
}
return DDD;
}(BB));
//// [override8.d.ts]
declare class B {
a: string;
}
declare class D extends B {
a: string;
b: string;
constructor(a: string, b: string);
}
declare class BB {
a: string;
constructor(a: string);
}
declare class DD extends BB {
a: string;
constructor(a: string);
}
declare class DDD extends BB {
a: string;
constructor(a: string);
}
@@ -0,0 +1,64 @@
=== tests/cases/conformance/override/override8.ts ===
class B {
>B : Symbol(B, Decl(override8.ts, 0, 0))
a: string
>a : Symbol(B.a, Decl(override8.ts, 0, 9))
}
class D extends B {
>D : Symbol(D, Decl(override8.ts, 2, 1))
>B : Symbol(B, Decl(override8.ts, 0, 0))
constructor(public a: string, public b: string) {
>a : Symbol(D.a, Decl(override8.ts, 5, 16))
>b : Symbol(D.b, Decl(override8.ts, 5, 33))
super();
>super : Symbol(B, Decl(override8.ts, 0, 0))
}
}
class BB {
>BB : Symbol(BB, Decl(override8.ts, 8, 1))
constructor(public a: string) {
>a : Symbol(BB.a, Decl(override8.ts, 11, 16))
}
}
class DD extends BB {
>DD : Symbol(DD, Decl(override8.ts, 14, 1))
>BB : Symbol(BB, Decl(override8.ts, 8, 1))
constructor(public a: string) {
>a : Symbol(DD.a, Decl(override8.ts, 17, 16))
super(a)
>super : Symbol(BB, Decl(override8.ts, 8, 1))
>a : Symbol(a, Decl(override8.ts, 17, 16))
}
}
class DDD extends BB {
>DDD : Symbol(DDD, Decl(override8.ts, 20, 1))
>BB : Symbol(BB, Decl(override8.ts, 8, 1))
public a: string;
>a : Symbol(DDD.a, Decl(override8.ts, 22, 22))
constructor(a: string) {
>a : Symbol(a, Decl(override8.ts, 25, 16))
super(a)
>super : Symbol(BB, Decl(override8.ts, 8, 1))
>a : Symbol(a, Decl(override8.ts, 25, 16))
this.a = a
>this.a : Symbol(DDD.a, Decl(override8.ts, 22, 22))
>this : Symbol(DDD, Decl(override8.ts, 20, 1))
>a : Symbol(DDD.a, Decl(override8.ts, 22, 22))
>a : Symbol(a, Decl(override8.ts, 25, 16))
}
}
+68
View File
@@ -0,0 +1,68 @@
=== tests/cases/conformance/override/override8.ts ===
class B {
>B : B
a: string
>a : string
}
class D extends B {
>D : D
>B : B
constructor(public a: string, public b: string) {
>a : string
>b : string
super();
>super() : void
>super : typeof B
}
}
class BB {
>BB : BB
constructor(public a: string) {
>a : string
}
}
class DD extends BB {
>DD : DD
>BB : BB
constructor(public a: string) {
>a : string
super(a)
>super(a) : void
>super : typeof BB
>a : string
}
}
class DDD extends BB {
>DDD : DDD
>BB : BB
public a: string;
>a : string
constructor(a: string) {
>a : string
super(a)
>super(a) : void
>super : typeof BB
>a : string
this.a = a
>this.a = a : string
>this.a : string
>this : this
>a : string
>a : string
}
}
@@ -0,0 +1,21 @@
tests/cases/conformance/override/override9.ts(8,5): error TS1070: 'override' modifier cannot appear on a type member.
tests/cases/conformance/override/override9.ts(10,5): error TS1070: 'override' modifier cannot appear on a type member.
==== tests/cases/conformance/override/override9.ts (2 errors) ====
interface B {
foo (): void
bar (): void
}
interface D extends B {
foo (): void;
override bar(): void;
~~~~~~~~
!!! error TS1070: 'override' modifier cannot appear on a type member.
baz(): void;
override bazz(): void;
~~~~~~~~
!!! error TS1070: 'override' modifier cannot appear on a type member.
}
+28
View File
@@ -0,0 +1,28 @@
//// [override9.ts]
interface B {
foo (): void
bar (): void
}
interface D extends B {
foo (): void;
override bar(): void;
baz(): void;
override bazz(): void;
}
//// [override9.js]
//// [override9.d.ts]
interface B {
foo(): void;
bar(): void;
}
interface D extends B {
foo(): void;
bar(): void;
baz(): void;
bazz(): void;
}
@@ -0,0 +1,28 @@
=== tests/cases/conformance/override/override9.ts ===
interface B {
>B : Symbol(B, Decl(override9.ts, 0, 0))
foo (): void
>foo : Symbol(B.foo, Decl(override9.ts, 0, 13))
bar (): void
>bar : Symbol(B.bar, Decl(override9.ts, 1, 16))
}
interface D extends B {
>D : Symbol(D, Decl(override9.ts, 3, 1))
>B : Symbol(B, Decl(override9.ts, 0, 0))
foo (): void;
>foo : Symbol(D.foo, Decl(override9.ts, 5, 23))
override bar(): void;
>bar : Symbol(D.bar, Decl(override9.ts, 6, 17))
baz(): void;
>baz : Symbol(D.baz, Decl(override9.ts, 7, 25))
override bazz(): void;
>bazz : Symbol(D.bazz, Decl(override9.ts, 8, 16))
}
+23
View File
@@ -0,0 +1,23 @@
=== tests/cases/conformance/override/override9.ts ===
interface B {
foo (): void
>foo : () => void
bar (): void
>bar : () => void
}
interface D extends B {
foo (): void;
>foo : () => void
override bar(): void;
>bar : () => void
baz(): void;
>baz : () => void
override bazz(): void;
>bazz : () => void
}
@@ -0,0 +1,64 @@
tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts(2,14): error TS4112: This member cannot have an 'override' modifier because its containing class 'AmbientClass' does not extend another class.
tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts(6,14): error TS4112: This member cannot have an 'override' modifier because its containing class 'NonAmbientClass' does not extend another class.
tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts(18,14): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'AmbientBase'.
tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts(31,18): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'AmbientBase'.
tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts(44,14): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'NonAmbientBase'.
==== tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts (5 errors) ====
export declare class AmbientClass {
override yadda(): void;
~~~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'AmbientClass' does not extend another class.
}
export class NonAmbientClass {
override yadda(): void {}
~~~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'NonAmbientClass' does not extend another class.
}
/////
export declare class AmbientBase {
foo(): void;
}
export declare class AmbientDerived extends AmbientBase {
foo(): void;
override bar(): void;
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'AmbientBase'.
}
/////
declare namespace ambientNamespace {
export class AmbientBase {
foo(): void;
}
export class AmbientDerived extends AmbientBase {
foo(): void;
override bar(): void;
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'AmbientBase'.
}
}
/////
export class NonAmbientBase {
foo(): void {}
}
export class NonAmbientDerived extends NonAmbientBase {
foo(): void {}
override bar(): void {}
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'NonAmbientBase'.
}
@@ -0,0 +1,92 @@
//// [overrideWithoutNoImplicitOverride1.ts]
export declare class AmbientClass {
override yadda(): void;
}
export class NonAmbientClass {
override yadda(): void {}
}
/////
export declare class AmbientBase {
foo(): void;
}
export declare class AmbientDerived extends AmbientBase {
foo(): void;
override bar(): void;
}
/////
declare namespace ambientNamespace {
export class AmbientBase {
foo(): void;
}
export class AmbientDerived extends AmbientBase {
foo(): void;
override bar(): void;
}
}
/////
export class NonAmbientBase {
foo(): void {}
}
export class NonAmbientDerived extends NonAmbientBase {
foo(): void {}
override bar(): void {}
}
//// [overrideWithoutNoImplicitOverride1.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
exports.NonAmbientDerived = exports.NonAmbientBase = exports.NonAmbientClass = void 0;
var NonAmbientClass = /** @class */ (function () {
function NonAmbientClass() {
}
NonAmbientClass.prototype.yadda = function () { };
return NonAmbientClass;
}());
exports.NonAmbientClass = NonAmbientClass;
/////
var NonAmbientBase = /** @class */ (function () {
function NonAmbientBase() {
}
NonAmbientBase.prototype.foo = function () { };
return NonAmbientBase;
}());
exports.NonAmbientBase = NonAmbientBase;
var NonAmbientDerived = /** @class */ (function (_super) {
__extends(NonAmbientDerived, _super);
function NonAmbientDerived() {
return _super !== null && _super.apply(this, arguments) || this;
}
NonAmbientDerived.prototype.foo = function () { };
NonAmbientDerived.prototype.bar = function () { };
return NonAmbientDerived;
}(NonAmbientBase));
exports.NonAmbientDerived = NonAmbientDerived;
@@ -0,0 +1,79 @@
=== tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts ===
export declare class AmbientClass {
>AmbientClass : Symbol(AmbientClass, Decl(overrideWithoutNoImplicitOverride1.ts, 0, 0))
override yadda(): void;
>yadda : Symbol(AmbientClass.yadda, Decl(overrideWithoutNoImplicitOverride1.ts, 0, 35))
}
export class NonAmbientClass {
>NonAmbientClass : Symbol(NonAmbientClass, Decl(overrideWithoutNoImplicitOverride1.ts, 2, 1))
override yadda(): void {}
>yadda : Symbol(NonAmbientClass.yadda, Decl(overrideWithoutNoImplicitOverride1.ts, 4, 30))
}
/////
export declare class AmbientBase {
>AmbientBase : Symbol(AmbientBase, Decl(overrideWithoutNoImplicitOverride1.ts, 6, 1))
foo(): void;
>foo : Symbol(AmbientBase.foo, Decl(overrideWithoutNoImplicitOverride1.ts, 10, 34))
}
export declare class AmbientDerived extends AmbientBase {
>AmbientDerived : Symbol(AmbientDerived, Decl(overrideWithoutNoImplicitOverride1.ts, 12, 1))
>AmbientBase : Symbol(AmbientBase, Decl(overrideWithoutNoImplicitOverride1.ts, 6, 1))
foo(): void;
>foo : Symbol(AmbientDerived.foo, Decl(overrideWithoutNoImplicitOverride1.ts, 14, 57))
override bar(): void;
>bar : Symbol(AmbientDerived.bar, Decl(overrideWithoutNoImplicitOverride1.ts, 15, 16))
}
/////
declare namespace ambientNamespace {
>ambientNamespace : Symbol(ambientNamespace, Decl(overrideWithoutNoImplicitOverride1.ts, 18, 1))
export class AmbientBase {
>AmbientBase : Symbol(AmbientBase, Decl(overrideWithoutNoImplicitOverride1.ts, 22, 36))
foo(): void;
>foo : Symbol(AmbientBase.foo, Decl(overrideWithoutNoImplicitOverride1.ts, 23, 30))
}
export class AmbientDerived extends AmbientBase {
>AmbientDerived : Symbol(AmbientDerived, Decl(overrideWithoutNoImplicitOverride1.ts, 25, 5))
>AmbientBase : Symbol(AmbientBase, Decl(overrideWithoutNoImplicitOverride1.ts, 22, 36))
foo(): void;
>foo : Symbol(AmbientDerived.foo, Decl(overrideWithoutNoImplicitOverride1.ts, 27, 53))
override bar(): void;
>bar : Symbol(AmbientDerived.bar, Decl(overrideWithoutNoImplicitOverride1.ts, 28, 20))
}
}
/////
export class NonAmbientBase {
>NonAmbientBase : Symbol(NonAmbientBase, Decl(overrideWithoutNoImplicitOverride1.ts, 32, 1))
foo(): void {}
>foo : Symbol(NonAmbientBase.foo, Decl(overrideWithoutNoImplicitOverride1.ts, 36, 29))
}
export class NonAmbientDerived extends NonAmbientBase {
>NonAmbientDerived : Symbol(NonAmbientDerived, Decl(overrideWithoutNoImplicitOverride1.ts, 38, 1))
>NonAmbientBase : Symbol(NonAmbientBase, Decl(overrideWithoutNoImplicitOverride1.ts, 32, 1))
foo(): void {}
>foo : Symbol(NonAmbientDerived.foo, Decl(overrideWithoutNoImplicitOverride1.ts, 40, 55))
override bar(): void {}
>bar : Symbol(NonAmbientDerived.bar, Decl(overrideWithoutNoImplicitOverride1.ts, 41, 18))
}
@@ -0,0 +1,79 @@
=== tests/cases/conformance/override/overrideWithoutNoImplicitOverride1.ts ===
export declare class AmbientClass {
>AmbientClass : AmbientClass
override yadda(): void;
>yadda : () => void
}
export class NonAmbientClass {
>NonAmbientClass : NonAmbientClass
override yadda(): void {}
>yadda : () => void
}
/////
export declare class AmbientBase {
>AmbientBase : AmbientBase
foo(): void;
>foo : () => void
}
export declare class AmbientDerived extends AmbientBase {
>AmbientDerived : AmbientDerived
>AmbientBase : AmbientBase
foo(): void;
>foo : () => void
override bar(): void;
>bar : () => void
}
/////
declare namespace ambientNamespace {
>ambientNamespace : typeof ambientNamespace
export class AmbientBase {
>AmbientBase : AmbientBase
foo(): void;
>foo : () => void
}
export class AmbientDerived extends AmbientBase {
>AmbientDerived : AmbientDerived
>AmbientBase : AmbientBase
foo(): void;
>foo : () => void
override bar(): void;
>bar : () => void
}
}
/////
export class NonAmbientBase {
>NonAmbientBase : NonAmbientBase
foo(): void {}
>foo : () => void
}
export class NonAmbientDerived extends NonAmbientBase {
>NonAmbientDerived : NonAmbientDerived
>NonAmbientBase : NonAmbientBase
foo(): void {}
>foo : () => void
override bar(): void {}
>bar : () => void
}
@@ -0,0 +1,48 @@
=== tests/cases/conformance/override/a.js ===
class B {
>B : Symbol(B, Decl(a.js, 0, 0))
foo (v) {}
>foo : Symbol(B.foo, Decl(a.js, 0, 9))
>v : Symbol(v, Decl(a.js, 1, 9))
fooo (v) {}
>fooo : Symbol(B.fooo, Decl(a.js, 1, 14))
>v : Symbol(v, Decl(a.js, 2, 10))
}
class D extends B {
>D : Symbol(D, Decl(a.js, 3, 1))
>B : Symbol(B, Decl(a.js, 0, 0))
foo (v) {}
>foo : Symbol(D.foo, Decl(a.js, 5, 19))
>v : Symbol(v, Decl(a.js, 6, 9))
/** @override */
fooo (v) {}
>fooo : Symbol(D.fooo, Decl(a.js, 6, 14))
>v : Symbol(v, Decl(a.js, 8, 10))
/** @override */
bar(v) {}
>bar : Symbol(D.bar, Decl(a.js, 8, 15))
>v : Symbol(v, Decl(a.js, 10, 8))
}
class C {
>C : Symbol(C, Decl(a.js, 11, 1))
foo () {}
>foo : Symbol(C.foo, Decl(a.js, 13, 9))
/** @override */
fooo (v) {}
>fooo : Symbol(C.fooo, Decl(a.js, 14, 13))
>v : Symbol(v, Decl(a.js, 16, 10))
/** @override */
bar(v) {}
>bar : Symbol(C.bar, Decl(a.js, 16, 15))
>v : Symbol(v, Decl(a.js, 18, 8))
}
@@ -0,0 +1,48 @@
=== tests/cases/conformance/override/a.js ===
class B {
>B : B
foo (v) {}
>foo : (v: any) => void
>v : any
fooo (v) {}
>fooo : (v: any) => void
>v : any
}
class D extends B {
>D : D
>B : B
foo (v) {}
>foo : (v: any) => void
>v : any
/** @override */
fooo (v) {}
>fooo : (v: any) => void
>v : any
/** @override */
bar(v) {}
>bar : (v: any) => void
>v : any
}
class C {
>C : C
foo () {}
>foo : () => void
/** @override */
fooo (v) {}
>fooo : (v: any) => void
>v : any
/** @override */
bar(v) {}
>bar : (v: any) => void
>v : any
}
@@ -0,0 +1,35 @@
tests/cases/conformance/override/a.js(7,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
tests/cases/conformance/override/a.js(11,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
tests/cases/conformance/override/a.js(17,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
tests/cases/conformance/override/a.js(19,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
==== tests/cases/conformance/override/a.js (4 errors) ====
class B {
foo (v) {}
fooo (v) {}
}
class D extends B {
foo (v) {}
~~~
!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'.
/** @override */
fooo (v) {}
/** @override */
bar(v) {}
~~~
!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'.
}
class C {
foo () {}
/** @override */
fooo (v) {}
~~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
/** @override */
bar(v) {}
~~~
!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class.
}
@@ -0,0 +1,48 @@
=== tests/cases/conformance/override/a.js ===
class B {
>B : Symbol(B, Decl(a.js, 0, 0))
foo (v) {}
>foo : Symbol(B.foo, Decl(a.js, 0, 9))
>v : Symbol(v, Decl(a.js, 1, 9))
fooo (v) {}
>fooo : Symbol(B.fooo, Decl(a.js, 1, 14))
>v : Symbol(v, Decl(a.js, 2, 10))
}
class D extends B {
>D : Symbol(D, Decl(a.js, 3, 1))
>B : Symbol(B, Decl(a.js, 0, 0))
foo (v) {}
>foo : Symbol(D.foo, Decl(a.js, 5, 19))
>v : Symbol(v, Decl(a.js, 6, 9))
/** @override */
fooo (v) {}
>fooo : Symbol(D.fooo, Decl(a.js, 6, 14))
>v : Symbol(v, Decl(a.js, 8, 10))
/** @override */
bar(v) {}
>bar : Symbol(D.bar, Decl(a.js, 8, 15))
>v : Symbol(v, Decl(a.js, 10, 8))
}
class C {
>C : Symbol(C, Decl(a.js, 11, 1))
foo () {}
>foo : Symbol(C.foo, Decl(a.js, 13, 9))
/** @override */
fooo (v) {}
>fooo : Symbol(C.fooo, Decl(a.js, 14, 13))
>v : Symbol(v, Decl(a.js, 16, 10))
/** @override */
bar(v) {}
>bar : Symbol(C.bar, Decl(a.js, 16, 15))
>v : Symbol(v, Decl(a.js, 18, 8))
}
@@ -0,0 +1,48 @@
=== tests/cases/conformance/override/a.js ===
class B {
>B : B
foo (v) {}
>foo : (v: any) => void
>v : any
fooo (v) {}
>fooo : (v: any) => void
>v : any
}
class D extends B {
>D : D
>B : B
foo (v) {}
>foo : (v: any) => void
>v : any
/** @override */
fooo (v) {}
>fooo : (v: any) => void
>v : any
/** @override */
bar(v) {}
>bar : (v: any) => void
>v : any
}
class C {
>C : C
foo () {}
>foo : () => void
/** @override */
fooo (v) {}
>fooo : (v: any) => void
>v : any
/** @override */
bar(v) {}
>bar : (v: any) => void
>v : any
}
@@ -0,0 +1,17 @@
tests/cases/conformance/override/a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files.
==== tests/cases/conformance/override/a.js (1 errors) ====
class B {
foo (v) {}
fooo (v) {}
}
class D extends B {
override foo (v) {}
~~~~~~~~
!!! error TS8009: The 'override' modifier can only be used in TypeScript files.
/** @override */
fooo (v) {}
}
@@ -0,0 +1,27 @@
=== tests/cases/conformance/override/a.js ===
class B {
>B : Symbol(B, Decl(a.js, 0, 0))
foo (v) {}
>foo : Symbol(B.foo, Decl(a.js, 0, 9))
>v : Symbol(v, Decl(a.js, 1, 9))
fooo (v) {}
>fooo : Symbol(B.fooo, Decl(a.js, 1, 14))
>v : Symbol(v, Decl(a.js, 2, 10))
}
class D extends B {
>D : Symbol(D, Decl(a.js, 3, 1))
>B : Symbol(B, Decl(a.js, 0, 0))
override foo (v) {}
>foo : Symbol(D.foo, Decl(a.js, 5, 19))
>v : Symbol(v, Decl(a.js, 6, 18))
/** @override */
fooo (v) {}
>fooo : Symbol(D.fooo, Decl(a.js, 6, 23))
>v : Symbol(v, Decl(a.js, 8, 10))
}
@@ -0,0 +1,27 @@
=== tests/cases/conformance/override/a.js ===
class B {
>B : B
foo (v) {}
>foo : (v: any) => void
>v : any
fooo (v) {}
>fooo : (v: any) => void
>v : any
}
class D extends B {
>D : D
>B : B
override foo (v) {}
>foo : (v: any) => void
>v : any
/** @override */
fooo (v) {}
>fooo : (v: any) => void
>v : any
}
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"noImplicitOverride": true
}
}
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"pedanticOverride": true
}
}
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -40,6 +40,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -61,6 +61,7 @@ interface Array<T> { length: number; [n: number]: T; }
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -61,6 +61,7 @@ interface Array<T> { length: number; [n: number]: T; }
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -61,6 +61,7 @@ interface Array<T> { length: number; [n: number]: T; }
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -61,6 +61,7 @@ interface Array<T> { length: number; [n: number]: T; }
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -61,6 +61,7 @@ interface Array<T> { length: number; [n: number]: T; }
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -61,6 +61,7 @@ interface Array<T> { length: number; [n: number]: T; }
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
@@ -0,0 +1,49 @@
// @allowJS: true
// @checkJS: true
// @noEmit: true
// @noImplicitOverride: true
// @Filename: 0.js
class A {
/**
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
return typeof a === 'string'
}
bar () {
}
}
class B extends A {
/**
* @override
* @method
* @param {string | number} a
* @returns {boolean}
*/
foo (a) {
return super.foo(a)
}
bar () {
}
/** @override */
baz () {
}
}
class C {
/** @override */
foo () {
}
}
@@ -0,0 +1,46 @@
// @declaration: true
// @noImplicitOverride: true
class B {
foo (v: string) {}
fooo (v: string) {}
}
class D extends B {
override foo (v: string) {}
fooo (v: string) {}
override bar(v: string) {}
}
class C {
override foo(v: string) {}
}
function f () {
return class extends B {
override foo (v: string) {}
fooo (v: string) {}
override bar(v: string) {}
}
}
class E extends (class {
foo () { }
bar () { }
}) {
override foo () { }
bar () { }
baz() {}
override bazz () {}
}
function ff () {
return class {
override foo () {}
}
}
@@ -0,0 +1,13 @@
// @declaration: true
// @noImplicitOverride: true
abstract class Base {
abstract foo(): unknown;
abstract bar(): void;
}
// No errors:
abstract class Sub extends Base {
override abstract foo(): number;
bar() { }
}
@@ -0,0 +1,9 @@
class Base {
foo = 1;
}
class Sub extends Base {
constructor (override public foo: number) {
super();
}
}
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff. Show more