-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error on
override
used on dynamically named class members (#60691)
- Loading branch information
Showing
29 changed files
with
1,358 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
} | ||
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
|
74 changes: 74 additions & 0 deletions
74
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
> : ^^^^^^ | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
} | ||
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
|
Oops, something went wrong.