From 239a2a936f30de0172d1700695c8f746e9009255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 6 Dec 2024 20:05:25 +0100 Subject: [PATCH] Error on `override` used on dynamically named class members (#60691) --- src/compiler/checker.ts | 9 +++ src/compiler/diagnosticMessages.json | 8 ++ ...Name1(noimplicitoverride=false).errors.txt | 33 ++++++++ ...eDynamicName1(noimplicitoverride=false).js | 49 ++++++++++++ ...micName1(noimplicitoverride=false).symbols | 52 +++++++++++++ ...namicName1(noimplicitoverride=false).types | 74 ++++++++++++++++++ ...cName1(noimplicitoverride=true).errors.txt | 33 ++++++++ ...deDynamicName1(noimplicitoverride=true).js | 49 ++++++++++++ ...amicName1(noimplicitoverride=true).symbols | 52 +++++++++++++ ...ynamicName1(noimplicitoverride=true).types | 74 ++++++++++++++++++ ...ture1(noimplicitoverride=false).errors.txt | 33 ++++++++ ...dexSignature1(noimplicitoverride=false).js | 49 ++++++++++++ ...gnature1(noimplicitoverride=false).symbols | 53 +++++++++++++ ...Signature1(noimplicitoverride=false).types | 76 +++++++++++++++++++ ...ature1(noimplicitoverride=true).errors.txt | 33 ++++++++ ...ndexSignature1(noimplicitoverride=true).js | 49 ++++++++++++ ...ignature1(noimplicitoverride=true).symbols | 53 +++++++++++++ ...xSignature1(noimplicitoverride=true).types | 76 +++++++++++++++++++ ...Name1(noimplicitoverride=false).errors.txt | 30 ++++++++ ...BindableName1(noimplicitoverride=false).js | 49 ++++++++++++ ...bleName1(noimplicitoverride=false).symbols | 52 +++++++++++++ ...dableName1(noimplicitoverride=false).types | 74 ++++++++++++++++++ ...eName1(noimplicitoverride=true).errors.txt | 33 ++++++++ ...eBindableName1(noimplicitoverride=true).js | 49 ++++++++++++ ...ableName1(noimplicitoverride=true).symbols | 52 +++++++++++++ ...ndableName1(noimplicitoverride=true).types | 74 ++++++++++++++++++ .../override/overrideDynamicName1.ts | 30 ++++++++ .../overrideLateBindableIndexSignature1.ts | 30 ++++++++ .../override/overrideLateBindableName1.ts | 30 ++++++++ 29 files changed, 1358 insertions(+) create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).errors.txt create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).symbols create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).types create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).errors.txt create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).symbols create mode 100644 tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).types create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).errors.txt create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).symbols create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).types create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).errors.txt create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).symbols create mode 100644 tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).types create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).errors.txt create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).js create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).symbols create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).types create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).errors.txt create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).js create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).symbols create mode 100644 tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).types create mode 100644 tests/cases/conformance/override/overrideDynamicName1.ts create mode 100644 tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts create mode 100644 tests/cases/conformance/override/overrideLateBindableName1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2dbd59bf51ef4..b439b7fd9c579 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -46774,6 +46774,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ): MemberOverrideStatus { const isJs = isInJSFile(node); const nodeInAmbientContext = !!(node.flags & NodeFlags.Ambient); + if (memberHasOverrideModifier && member?.valueDeclaration && isClassElement(member.valueDeclaration) && member.valueDeclaration.name && isNonBindableDynamicName(member.valueDeclaration.name)) { + error( + errorNode, + isJs ? + Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic : + Diagnostics.This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic, + ); + return MemberOverrideStatus.HasInvalidOverride; + } if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { const thisType = memberIsStatic ? staticType : typeWithThis; const baseType = memberIsStatic ? baseStaticType : baseWithThis; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7f686076f1824..0b2951d8dee2d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4417,6 +4417,14 @@ "category": "Error", "code": 4126 }, + "This member cannot have an 'override' modifier because its name is dynamic.": { + "category": "Error", + "code": 4127 + }, + "This member cannot have a JSDoc comment with an '@override' tag because its name is dynamic.": { + "category": "Error", + "code": 4128 + }, "The current host does not support the '{0}' option.": { "category": "Error", diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).errors.txt b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).errors.txt new file mode 100644 index 0000000000000..dc4b60e7ee311 --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).errors.txt @@ -0,0 +1,33 @@ +overrideDynamicName1.ts(8,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. +overrideDynamicName1.ts(22,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + + +==== overrideDynamicName1.ts (2 errors) ==== + let prop = "foo" + + class Base1 { + [prop]() {} + } + + class Derived1 extends Base1 { + override [prop]() {} + ~~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + + class Base2 { + [prop]() {} + } + + class Derived2 extends Base2 { + [prop]() {} + } + + class Base3 {} + + class Derived3 extends Base3 { + override [prop]() {} + ~~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + \ No newline at end of file diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js new file mode 100644 index 0000000000000..9066e8c7d57a3 --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/override/overrideDynamicName1.ts] //// + +//// [overrideDynamicName1.ts] +let prop = "foo" + +class Base1 { + [prop]() {} +} + +class Derived1 extends Base1 { + override [prop]() {} +} + +class Base2 { + [prop]() {} +} + +class Derived2 extends Base2 { + [prop]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [prop]() {} +} + + + + +//// [overrideDynamicName1.d.ts] +declare let prop: string; +declare class Base1 { + [x: string]: () => void; +} +declare class Derived1 extends Base1 { + [x: string]: () => void; +} +declare class Base2 { + [x: string]: () => void; +} +declare class Derived2 extends Base2 { + [x: string]: () => void; +} +declare class Base3 { +} +declare class Derived3 extends Base3 { + [x: string]: () => void; +} diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).symbols b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).symbols new file mode 100644 index 0000000000000..3f4a38edda3f5 --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).symbols @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/override/overrideDynamicName1.ts] //// + +=== overrideDynamicName1.ts === +let prop = "foo" +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) + +class Base1 { +>Base1 : Symbol(Base1, Decl(overrideDynamicName1.ts, 0, 16)) + + [prop]() {} +>[prop] : Symbol(Base1[prop], Decl(overrideDynamicName1.ts, 2, 13)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(overrideDynamicName1.ts, 4, 1)) +>Base1 : Symbol(Base1, Decl(overrideDynamicName1.ts, 0, 16)) + + override [prop]() {} +>[prop] : Symbol(Derived1[prop], Decl(overrideDynamicName1.ts, 6, 30)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(overrideDynamicName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Base2[prop], Decl(overrideDynamicName1.ts, 10, 13)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(overrideDynamicName1.ts, 12, 1)) +>Base2 : Symbol(Base2, Decl(overrideDynamicName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Derived2[prop], Decl(overrideDynamicName1.ts, 14, 30)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Base3 {} +>Base3 : Symbol(Base3, Decl(overrideDynamicName1.ts, 16, 1)) + +class Derived3 extends Base3 { +>Derived3 : Symbol(Derived3, Decl(overrideDynamicName1.ts, 18, 14)) +>Base3 : Symbol(Base3, Decl(overrideDynamicName1.ts, 16, 1)) + + override [prop]() {} +>[prop] : Symbol(Derived3[prop], Decl(overrideDynamicName1.ts, 20, 30)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).types b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).types new file mode 100644 index 0000000000000..c544cdb87396c --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).types @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/override/overrideDynamicName1.ts] //// + +=== overrideDynamicName1.ts === +let prop = "foo" +>prop : string +> : ^^^^^^ +>"foo" : "foo" +> : ^^^^^ + +class Base1 { +>Base1 : Base1 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Derived1 extends Base1 { +>Derived1 : Derived1 +> : ^^^^^^^^ +>Base1 : Base1 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Base2 { +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Derived2 extends Base2 { +>Derived2 : Derived2 +> : ^^^^^^^^ +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Base3 {} +>Base3 : Base3 +> : ^^^^^ + +class Derived3 extends Base3 { +>Derived3 : Derived3 +> : ^^^^^^^^ +>Base3 : Base3 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).errors.txt b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).errors.txt new file mode 100644 index 0000000000000..dc4b60e7ee311 --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).errors.txt @@ -0,0 +1,33 @@ +overrideDynamicName1.ts(8,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. +overrideDynamicName1.ts(22,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + + +==== overrideDynamicName1.ts (2 errors) ==== + let prop = "foo" + + class Base1 { + [prop]() {} + } + + class Derived1 extends Base1 { + override [prop]() {} + ~~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + + class Base2 { + [prop]() {} + } + + class Derived2 extends Base2 { + [prop]() {} + } + + class Base3 {} + + class Derived3 extends Base3 { + override [prop]() {} + ~~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + \ No newline at end of file diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js new file mode 100644 index 0000000000000..9066e8c7d57a3 --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/override/overrideDynamicName1.ts] //// + +//// [overrideDynamicName1.ts] +let prop = "foo" + +class Base1 { + [prop]() {} +} + +class Derived1 extends Base1 { + override [prop]() {} +} + +class Base2 { + [prop]() {} +} + +class Derived2 extends Base2 { + [prop]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [prop]() {} +} + + + + +//// [overrideDynamicName1.d.ts] +declare let prop: string; +declare class Base1 { + [x: string]: () => void; +} +declare class Derived1 extends Base1 { + [x: string]: () => void; +} +declare class Base2 { + [x: string]: () => void; +} +declare class Derived2 extends Base2 { + [x: string]: () => void; +} +declare class Base3 { +} +declare class Derived3 extends Base3 { + [x: string]: () => void; +} diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).symbols b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).symbols new file mode 100644 index 0000000000000..3f4a38edda3f5 --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).symbols @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/override/overrideDynamicName1.ts] //// + +=== overrideDynamicName1.ts === +let prop = "foo" +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) + +class Base1 { +>Base1 : Symbol(Base1, Decl(overrideDynamicName1.ts, 0, 16)) + + [prop]() {} +>[prop] : Symbol(Base1[prop], Decl(overrideDynamicName1.ts, 2, 13)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(overrideDynamicName1.ts, 4, 1)) +>Base1 : Symbol(Base1, Decl(overrideDynamicName1.ts, 0, 16)) + + override [prop]() {} +>[prop] : Symbol(Derived1[prop], Decl(overrideDynamicName1.ts, 6, 30)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(overrideDynamicName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Base2[prop], Decl(overrideDynamicName1.ts, 10, 13)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(overrideDynamicName1.ts, 12, 1)) +>Base2 : Symbol(Base2, Decl(overrideDynamicName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Derived2[prop], Decl(overrideDynamicName1.ts, 14, 30)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + +class Base3 {} +>Base3 : Symbol(Base3, Decl(overrideDynamicName1.ts, 16, 1)) + +class Derived3 extends Base3 { +>Derived3 : Symbol(Derived3, Decl(overrideDynamicName1.ts, 18, 14)) +>Base3 : Symbol(Base3, Decl(overrideDynamicName1.ts, 16, 1)) + + override [prop]() {} +>[prop] : Symbol(Derived3[prop], Decl(overrideDynamicName1.ts, 20, 30)) +>prop : Symbol(prop, Decl(overrideDynamicName1.ts, 0, 3)) +} + diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).types b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).types new file mode 100644 index 0000000000000..c544cdb87396c --- /dev/null +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).types @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/override/overrideDynamicName1.ts] //// + +=== overrideDynamicName1.ts === +let prop = "foo" +>prop : string +> : ^^^^^^ +>"foo" : "foo" +> : ^^^^^ + +class Base1 { +>Base1 : Base1 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Derived1 extends Base1 { +>Derived1 : Derived1 +> : ^^^^^^^^ +>Base1 : Base1 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Base2 { +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Derived2 extends Base2 { +>Derived2 : Derived2 +> : ^^^^^^^^ +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + +class Base3 {} +>Base3 : Base3 +> : ^^^^^ + +class Derived3 extends Base3 { +>Derived3 : Derived3 +> : ^^^^^^^^ +>Base3 : Base3 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : string +> : ^^^^^^ +} + diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).errors.txt b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).errors.txt new file mode 100644 index 0000000000000..32329c5769715 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).errors.txt @@ -0,0 +1,33 @@ +overrideLateBindableIndexSignature1.ts(8,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. +overrideLateBindableIndexSignature1.ts(22,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + + +==== overrideLateBindableIndexSignature1.ts (2 errors) ==== + const sym: symbol = Symbol(); + + class Base1 { + [sym]() {} + } + + class Derived1 extends Base1 { + override [sym]() {} + ~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + + class Base2 { + [sym]() {} + } + + class Derived2 extends Base2 { + [sym]() {} + } + + class Base3 {} + + class Derived3 extends Base3 { + override [sym]() {} + ~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + \ No newline at end of file diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js new file mode 100644 index 0000000000000..d02cbd16d47ea --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts] //// + +//// [overrideLateBindableIndexSignature1.ts] +const sym: symbol = Symbol(); + +class Base1 { + [sym]() {} +} + +class Derived1 extends Base1 { + override [sym]() {} +} + +class Base2 { + [sym]() {} +} + +class Derived2 extends Base2 { + [sym]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [sym]() {} +} + + + + +//// [overrideLateBindableIndexSignature1.d.ts] +declare const sym: symbol; +declare class Base1 { + [x: symbol]: () => void; +} +declare class Derived1 extends Base1 { + [x: symbol]: () => void; +} +declare class Base2 { + [x: symbol]: () => void; +} +declare class Derived2 extends Base2 { + [x: symbol]: () => void; +} +declare class Base3 { +} +declare class Derived3 extends Base3 { + [x: symbol]: () => void; +} diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).symbols b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).symbols new file mode 100644 index 0000000000000..cdf2b6c5f707a --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).symbols @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts] //// + +=== overrideLateBindableIndexSignature1.ts === +const sym: symbol = Symbol(); +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) + +class Base1 { +>Base1 : Symbol(Base1, Decl(overrideLateBindableIndexSignature1.ts, 0, 29)) + + [sym]() {} +>[sym] : Symbol(Base1[sym], Decl(overrideLateBindableIndexSignature1.ts, 2, 13)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(overrideLateBindableIndexSignature1.ts, 4, 1)) +>Base1 : Symbol(Base1, Decl(overrideLateBindableIndexSignature1.ts, 0, 29)) + + override [sym]() {} +>[sym] : Symbol(Derived1[sym], Decl(overrideLateBindableIndexSignature1.ts, 6, 30)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(overrideLateBindableIndexSignature1.ts, 8, 1)) + + [sym]() {} +>[sym] : Symbol(Base2[sym], Decl(overrideLateBindableIndexSignature1.ts, 10, 13)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(overrideLateBindableIndexSignature1.ts, 12, 1)) +>Base2 : Symbol(Base2, Decl(overrideLateBindableIndexSignature1.ts, 8, 1)) + + [sym]() {} +>[sym] : Symbol(Derived2[sym], Decl(overrideLateBindableIndexSignature1.ts, 14, 30)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Base3 {} +>Base3 : Symbol(Base3, Decl(overrideLateBindableIndexSignature1.ts, 16, 1)) + +class Derived3 extends Base3 { +>Derived3 : Symbol(Derived3, Decl(overrideLateBindableIndexSignature1.ts, 18, 14)) +>Base3 : Symbol(Base3, Decl(overrideLateBindableIndexSignature1.ts, 16, 1)) + + override [sym]() {} +>[sym] : Symbol(Derived3[sym], Decl(overrideLateBindableIndexSignature1.ts, 20, 30)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).types b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).types new file mode 100644 index 0000000000000..69358487e96b2 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).types @@ -0,0 +1,76 @@ +//// [tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts] //// + +=== overrideLateBindableIndexSignature1.ts === +const sym: symbol = Symbol(); +>sym : symbol +> : ^^^^^^ +>Symbol() : unique symbol +> : ^^^^^^^^^^^^^ +>Symbol : SymbolConstructor +> : ^^^^^^^^^^^^^^^^^ + +class Base1 { +>Base1 : Base1 +> : ^^^^^ + + [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Derived1 extends Base1 { +>Derived1 : Derived1 +> : ^^^^^^^^ +>Base1 : Base1 +> : ^^^^^ + + override [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Base2 { +>Base2 : Base2 +> : ^^^^^ + + [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Derived2 extends Base2 { +>Derived2 : Derived2 +> : ^^^^^^^^ +>Base2 : Base2 +> : ^^^^^ + + [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Base3 {} +>Base3 : Base3 +> : ^^^^^ + +class Derived3 extends Base3 { +>Derived3 : Derived3 +> : ^^^^^^^^ +>Base3 : Base3 +> : ^^^^^ + + override [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).errors.txt b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).errors.txt new file mode 100644 index 0000000000000..32329c5769715 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).errors.txt @@ -0,0 +1,33 @@ +overrideLateBindableIndexSignature1.ts(8,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. +overrideLateBindableIndexSignature1.ts(22,12): error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + + +==== overrideLateBindableIndexSignature1.ts (2 errors) ==== + const sym: symbol = Symbol(); + + class Base1 { + [sym]() {} + } + + class Derived1 extends Base1 { + override [sym]() {} + ~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + + class Base2 { + [sym]() {} + } + + class Derived2 extends Base2 { + [sym]() {} + } + + class Base3 {} + + class Derived3 extends Base3 { + override [sym]() {} + ~~~~~ +!!! error TS4127: This member cannot have an 'override' modifier because its name is dynamic. + } + \ No newline at end of file diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js new file mode 100644 index 0000000000000..d02cbd16d47ea --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts] //// + +//// [overrideLateBindableIndexSignature1.ts] +const sym: symbol = Symbol(); + +class Base1 { + [sym]() {} +} + +class Derived1 extends Base1 { + override [sym]() {} +} + +class Base2 { + [sym]() {} +} + +class Derived2 extends Base2 { + [sym]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [sym]() {} +} + + + + +//// [overrideLateBindableIndexSignature1.d.ts] +declare const sym: symbol; +declare class Base1 { + [x: symbol]: () => void; +} +declare class Derived1 extends Base1 { + [x: symbol]: () => void; +} +declare class Base2 { + [x: symbol]: () => void; +} +declare class Derived2 extends Base2 { + [x: symbol]: () => void; +} +declare class Base3 { +} +declare class Derived3 extends Base3 { + [x: symbol]: () => void; +} diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).symbols b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).symbols new file mode 100644 index 0000000000000..cdf2b6c5f707a --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).symbols @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts] //// + +=== overrideLateBindableIndexSignature1.ts === +const sym: symbol = Symbol(); +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) + +class Base1 { +>Base1 : Symbol(Base1, Decl(overrideLateBindableIndexSignature1.ts, 0, 29)) + + [sym]() {} +>[sym] : Symbol(Base1[sym], Decl(overrideLateBindableIndexSignature1.ts, 2, 13)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(overrideLateBindableIndexSignature1.ts, 4, 1)) +>Base1 : Symbol(Base1, Decl(overrideLateBindableIndexSignature1.ts, 0, 29)) + + override [sym]() {} +>[sym] : Symbol(Derived1[sym], Decl(overrideLateBindableIndexSignature1.ts, 6, 30)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(overrideLateBindableIndexSignature1.ts, 8, 1)) + + [sym]() {} +>[sym] : Symbol(Base2[sym], Decl(overrideLateBindableIndexSignature1.ts, 10, 13)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(overrideLateBindableIndexSignature1.ts, 12, 1)) +>Base2 : Symbol(Base2, Decl(overrideLateBindableIndexSignature1.ts, 8, 1)) + + [sym]() {} +>[sym] : Symbol(Derived2[sym], Decl(overrideLateBindableIndexSignature1.ts, 14, 30)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + +class Base3 {} +>Base3 : Symbol(Base3, Decl(overrideLateBindableIndexSignature1.ts, 16, 1)) + +class Derived3 extends Base3 { +>Derived3 : Symbol(Derived3, Decl(overrideLateBindableIndexSignature1.ts, 18, 14)) +>Base3 : Symbol(Base3, Decl(overrideLateBindableIndexSignature1.ts, 16, 1)) + + override [sym]() {} +>[sym] : Symbol(Derived3[sym], Decl(overrideLateBindableIndexSignature1.ts, 20, 30)) +>sym : Symbol(sym, Decl(overrideLateBindableIndexSignature1.ts, 0, 5)) +} + diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).types b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).types new file mode 100644 index 0000000000000..69358487e96b2 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).types @@ -0,0 +1,76 @@ +//// [tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts] //// + +=== overrideLateBindableIndexSignature1.ts === +const sym: symbol = Symbol(); +>sym : symbol +> : ^^^^^^ +>Symbol() : unique symbol +> : ^^^^^^^^^^^^^ +>Symbol : SymbolConstructor +> : ^^^^^^^^^^^^^^^^^ + +class Base1 { +>Base1 : Base1 +> : ^^^^^ + + [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Derived1 extends Base1 { +>Derived1 : Derived1 +> : ^^^^^^^^ +>Base1 : Base1 +> : ^^^^^ + + override [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Base2 { +>Base2 : Base2 +> : ^^^^^ + + [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Derived2 extends Base2 { +>Derived2 : Derived2 +> : ^^^^^^^^ +>Base2 : Base2 +> : ^^^^^ + + [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + +class Base3 {} +>Base3 : Base3 +> : ^^^^^ + +class Derived3 extends Base3 { +>Derived3 : Derived3 +> : ^^^^^^^^ +>Base3 : Base3 +> : ^^^^^ + + override [sym]() {} +>[sym] : () => void +> : ^^^^^^^^^^ +>sym : symbol +> : ^^^^^^ +} + diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).errors.txt b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).errors.txt new file mode 100644 index 0000000000000..5222bde9970fc --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).errors.txt @@ -0,0 +1,30 @@ +overrideLateBindableName1.ts(22,12): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'Base3'. + + +==== overrideLateBindableName1.ts (1 errors) ==== + const prop = "foo" + + class Base1 { + [prop]() {} + } + + class Derived1 extends Base1 { + override [prop]() {} + } + + class Base2 { + [prop]() {} + } + + class Derived2 extends Base2 { + [prop]() {} + } + + class Base3 {} + + class Derived3 extends Base3 { + override [prop]() {} + ~~~~~~ +!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'Base3'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).js b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).js new file mode 100644 index 0000000000000..49e6c2c387705 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/override/overrideLateBindableName1.ts] //// + +//// [overrideLateBindableName1.ts] +const prop = "foo" + +class Base1 { + [prop]() {} +} + +class Derived1 extends Base1 { + override [prop]() {} +} + +class Base2 { + [prop]() {} +} + +class Derived2 extends Base2 { + [prop]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [prop]() {} +} + + + + +//// [overrideLateBindableName1.d.ts] +declare const prop = "foo"; +declare class Base1 { + [prop](): void; +} +declare class Derived1 extends Base1 { + [prop](): void; +} +declare class Base2 { + [prop](): void; +} +declare class Derived2 extends Base2 { + [prop](): void; +} +declare class Base3 { +} +declare class Derived3 extends Base3 { + [prop](): void; +} diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).symbols b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).symbols new file mode 100644 index 0000000000000..af7e39c350b18 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).symbols @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/override/overrideLateBindableName1.ts] //// + +=== overrideLateBindableName1.ts === +const prop = "foo" +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) + +class Base1 { +>Base1 : Symbol(Base1, Decl(overrideLateBindableName1.ts, 0, 18)) + + [prop]() {} +>[prop] : Symbol(Base1[prop], Decl(overrideLateBindableName1.ts, 2, 13)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(overrideLateBindableName1.ts, 4, 1)) +>Base1 : Symbol(Base1, Decl(overrideLateBindableName1.ts, 0, 18)) + + override [prop]() {} +>[prop] : Symbol(Derived1[prop], Decl(overrideLateBindableName1.ts, 6, 30)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(overrideLateBindableName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Base2[prop], Decl(overrideLateBindableName1.ts, 10, 13)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(overrideLateBindableName1.ts, 12, 1)) +>Base2 : Symbol(Base2, Decl(overrideLateBindableName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Derived2[prop], Decl(overrideLateBindableName1.ts, 14, 30)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Base3 {} +>Base3 : Symbol(Base3, Decl(overrideLateBindableName1.ts, 16, 1)) + +class Derived3 extends Base3 { +>Derived3 : Symbol(Derived3, Decl(overrideLateBindableName1.ts, 18, 14)) +>Base3 : Symbol(Base3, Decl(overrideLateBindableName1.ts, 16, 1)) + + override [prop]() {} +>[prop] : Symbol(Derived3[prop], Decl(overrideLateBindableName1.ts, 20, 30)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).types b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).types new file mode 100644 index 0000000000000..1f1c75c1c39d8 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=false).types @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/override/overrideLateBindableName1.ts] //// + +=== overrideLateBindableName1.ts === +const prop = "foo" +>prop : "foo" +> : ^^^^^ +>"foo" : "foo" +> : ^^^^^ + +class Base1 { +>Base1 : Base1 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Derived1 extends Base1 { +>Derived1 : Derived1 +> : ^^^^^^^^ +>Base1 : Base1 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Base2 { +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Derived2 extends Base2 { +>Derived2 : Derived2 +> : ^^^^^^^^ +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Base3 {} +>Base3 : Base3 +> : ^^^^^ + +class Derived3 extends Base3 { +>Derived3 : Derived3 +> : ^^^^^^^^ +>Base3 : Base3 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).errors.txt b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).errors.txt new file mode 100644 index 0000000000000..7511c3468b334 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).errors.txt @@ -0,0 +1,33 @@ +overrideLateBindableName1.ts(16,3): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Base2'. +overrideLateBindableName1.ts(22,12): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'Base3'. + + +==== overrideLateBindableName1.ts (2 errors) ==== + const prop = "foo" + + class Base1 { + [prop]() {} + } + + class Derived1 extends Base1 { + override [prop]() {} + } + + class Base2 { + [prop]() {} + } + + class Derived2 extends Base2 { + [prop]() {} + ~~~~~~ +!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Base2'. + } + + class Base3 {} + + class Derived3 extends Base3 { + override [prop]() {} + ~~~~~~ +!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'Base3'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).js b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).js new file mode 100644 index 0000000000000..49e6c2c387705 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/override/overrideLateBindableName1.ts] //// + +//// [overrideLateBindableName1.ts] +const prop = "foo" + +class Base1 { + [prop]() {} +} + +class Derived1 extends Base1 { + override [prop]() {} +} + +class Base2 { + [prop]() {} +} + +class Derived2 extends Base2 { + [prop]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [prop]() {} +} + + + + +//// [overrideLateBindableName1.d.ts] +declare const prop = "foo"; +declare class Base1 { + [prop](): void; +} +declare class Derived1 extends Base1 { + [prop](): void; +} +declare class Base2 { + [prop](): void; +} +declare class Derived2 extends Base2 { + [prop](): void; +} +declare class Base3 { +} +declare class Derived3 extends Base3 { + [prop](): void; +} diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).symbols b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).symbols new file mode 100644 index 0000000000000..af7e39c350b18 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).symbols @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/override/overrideLateBindableName1.ts] //// + +=== overrideLateBindableName1.ts === +const prop = "foo" +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) + +class Base1 { +>Base1 : Symbol(Base1, Decl(overrideLateBindableName1.ts, 0, 18)) + + [prop]() {} +>[prop] : Symbol(Base1[prop], Decl(overrideLateBindableName1.ts, 2, 13)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(overrideLateBindableName1.ts, 4, 1)) +>Base1 : Symbol(Base1, Decl(overrideLateBindableName1.ts, 0, 18)) + + override [prop]() {} +>[prop] : Symbol(Derived1[prop], Decl(overrideLateBindableName1.ts, 6, 30)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(overrideLateBindableName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Base2[prop], Decl(overrideLateBindableName1.ts, 10, 13)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(overrideLateBindableName1.ts, 12, 1)) +>Base2 : Symbol(Base2, Decl(overrideLateBindableName1.ts, 8, 1)) + + [prop]() {} +>[prop] : Symbol(Derived2[prop], Decl(overrideLateBindableName1.ts, 14, 30)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + +class Base3 {} +>Base3 : Symbol(Base3, Decl(overrideLateBindableName1.ts, 16, 1)) + +class Derived3 extends Base3 { +>Derived3 : Symbol(Derived3, Decl(overrideLateBindableName1.ts, 18, 14)) +>Base3 : Symbol(Base3, Decl(overrideLateBindableName1.ts, 16, 1)) + + override [prop]() {} +>[prop] : Symbol(Derived3[prop], Decl(overrideLateBindableName1.ts, 20, 30)) +>prop : Symbol(prop, Decl(overrideLateBindableName1.ts, 0, 5)) +} + diff --git a/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).types b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).types new file mode 100644 index 0000000000000..1f1c75c1c39d8 --- /dev/null +++ b/tests/baselines/reference/overrideLateBindableName1(noimplicitoverride=true).types @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/override/overrideLateBindableName1.ts] //// + +=== overrideLateBindableName1.ts === +const prop = "foo" +>prop : "foo" +> : ^^^^^ +>"foo" : "foo" +> : ^^^^^ + +class Base1 { +>Base1 : Base1 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Derived1 extends Base1 { +>Derived1 : Derived1 +> : ^^^^^^^^ +>Base1 : Base1 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Base2 { +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Derived2 extends Base2 { +>Derived2 : Derived2 +> : ^^^^^^^^ +>Base2 : Base2 +> : ^^^^^ + + [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + +class Base3 {} +>Base3 : Base3 +> : ^^^^^ + +class Derived3 extends Base3 { +>Derived3 : Derived3 +> : ^^^^^^^^ +>Base3 : Base3 +> : ^^^^^ + + override [prop]() {} +>[prop] : () => void +> : ^^^^^^^^^^ +>prop : "foo" +> : ^^^^^ +} + diff --git a/tests/cases/conformance/override/overrideDynamicName1.ts b/tests/cases/conformance/override/overrideDynamicName1.ts new file mode 100644 index 0000000000000..d1962617a9b1f --- /dev/null +++ b/tests/cases/conformance/override/overrideDynamicName1.ts @@ -0,0 +1,30 @@ +// @strict: true +// @lib: esnext +// @target: esnext +// @noImplicitOverride: true, false +// @declaration: true +// @emitDeclarationOnly: true + +let prop = "foo" + +class Base1 { + [prop]() {} +} + +class Derived1 extends Base1 { + override [prop]() {} +} + +class Base2 { + [prop]() {} +} + +class Derived2 extends Base2 { + [prop]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [prop]() {} +} diff --git a/tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts b/tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts new file mode 100644 index 0000000000000..e30e90d6d0a5b --- /dev/null +++ b/tests/cases/conformance/override/overrideLateBindableIndexSignature1.ts @@ -0,0 +1,30 @@ +// @strict: true +// @lib: esnext +// @target: esnext +// @noImplicitOverride: true, false +// @declaration: true +// @emitDeclarationOnly: true + +const sym: symbol = Symbol(); + +class Base1 { + [sym]() {} +} + +class Derived1 extends Base1 { + override [sym]() {} +} + +class Base2 { + [sym]() {} +} + +class Derived2 extends Base2 { + [sym]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [sym]() {} +} diff --git a/tests/cases/conformance/override/overrideLateBindableName1.ts b/tests/cases/conformance/override/overrideLateBindableName1.ts new file mode 100644 index 0000000000000..0eec3d36ef58a --- /dev/null +++ b/tests/cases/conformance/override/overrideLateBindableName1.ts @@ -0,0 +1,30 @@ +// @strict: true +// @lib: esnext +// @target: esnext +// @noImplicitOverride: true, false +// @declaration: true +// @emitDeclarationOnly: true + +const prop = "foo" + +class Base1 { + [prop]() {} +} + +class Derived1 extends Base1 { + override [prop]() {} +} + +class Base2 { + [prop]() {} +} + +class Derived2 extends Base2 { + [prop]() {} +} + +class Base3 {} + +class Derived3 extends Base3 { + override [prop]() {} +}