Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12002,7 +12002,7 @@ func (c *Checker) checkPropertyAccessibilityAtLocation(location *ast.Node, isSup
// This is true for both [[Set]] (old) and [[Define]] (ES spec) semantics.
if flags&ast.ModifierFlagsStatic == 0 && core.Some(prop.Declarations, isClassInstanceProperty) {
if errorNode != nil {
c.error(errorNode, diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, c.symbolToString(prop))
c.error(errorNode, diagnostics.Instance_property_0_is_defined_by_the_superclass_and_must_be_accessed_through_this_not_super, c.symbolToString(prop))
}
return false
}
Expand Down
2 changes: 1 addition & 1 deletion tsc/internal/diagnostics/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3930,7 +3930,7 @@
"category": "Error",
"code": 2854
},
"Class field '{0}' defined by the parent class is not accessible in the child class via super.": {
"Instance property '{0}' is defined by the superclass and must be accessed through 'this', not 'super'.": {
"category": "Error",
"code": 2855
},
Expand Down
6 changes: 3 additions & 3 deletions tsc/internal/diagnostics/diagnostics_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified tsc/internal/diagnostics/loc/cs-CZ.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/de-DE.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/es-ES.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/fr-FR.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/it-IT.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/ja-JP.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/ko-KR.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/pl-PL.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/pt-BR.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/ru-RU.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/tr-TR.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/zh-CN.json.gz
Binary file not shown.
Binary file modified tsc/internal/diagnostics/loc/zh-TW.json.gz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
checkSuperCallBeforeThisAccess.ts(7,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(8,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(9,18): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(9,24): error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
checkSuperCallBeforeThisAccess.ts(12,30): error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
checkSuperCallBeforeThisAccess.ts(17,28): error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
checkSuperCallBeforeThisAccess.ts(9,24): error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
checkSuperCallBeforeThisAccess.ts(12,30): error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
checkSuperCallBeforeThisAccess.ts(17,28): error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
checkSuperCallBeforeThisAccess.ts(20,22): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(21,22): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(22,22): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(22,28): error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
checkSuperCallBeforeThisAccess.ts(22,28): error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
checkSuperCallBeforeThisAccess.ts(30,30): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(39,22): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(43,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(44,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(45,18): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(45,24): error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
checkSuperCallBeforeThisAccess.ts(45,24): error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
checkSuperCallBeforeThisAccess.ts(59,27): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.

Expand All @@ -35,19 +35,19 @@ checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 'super' must be called
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
~
!!! error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
let a4 = () => this;
let a5 = () => this.x;
let a6 = () => super.x;
~
!!! error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
if (!!true) {
super();
let b1 = this;
let b2 = this.x;
let b3 = super.x;
~
!!! error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
}
else {
let c1 = this; // Error
Expand All @@ -60,7 +60,7 @@ checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 'super' must be called
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
~
!!! error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
}
if (!!true) {
switch (n) {
Expand Down Expand Up @@ -95,7 +95,7 @@ checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 'super' must be called
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
~
!!! error TS2855: Class field 'x' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'x' is defined by the superclass and must be accessed through 'this', not 'super'.
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
classFieldSuperNotAccessible.ts(6,15): error TS2855: Class field 'field' defined by the parent class is not accessible in the child class via super.
classFieldSuperNotAccessible.ts(6,15): error TS2855: Instance property 'field' is defined by the superclass and must be accessed through 'this', not 'super'.


==== classFieldSuperNotAccessible.ts (1 errors) ====
Expand All @@ -9,7 +9,7 @@ classFieldSuperNotAccessible.ts(6,15): error TS2855: Class field 'field' defined
f() {
super.field() // error
~~~~~
!!! error TS2855: Class field 'field' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'field' is defined by the superclass and must be accessed through 'this', not 'super'.
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
index.js(7,14): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'.
index.js(9,9): error TS7053: Element implicitly has an 'any' type because expression of type '"literalElementAccess"' can't be used to index type 'YaddaBase'.
Property 'literalElementAccess' does not exist on type 'YaddaBase'.
index.js(20,22): error TS2855: Class field 'roots' defined by the parent class is not accessible in the child class via super.
index.js(23,22): error TS2855: Class field 'foo' defined by the parent class is not accessible in the child class via super.
index.js(20,22): error TS2855: Instance property 'roots' is defined by the superclass and must be accessed through 'this', not 'super'.
index.js(23,22): error TS2855: Instance property 'foo' is defined by the superclass and must be accessed through 'this', not 'super'.
index.js(26,22): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'.
index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on type 'YaddaBase'.

Expand Down Expand Up @@ -34,12 +34,12 @@ index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on
get rootTests() {
return super.roots;
~~~~~
!!! error TS2855: Class field 'roots' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'roots' is defined by the superclass and must be accessed through 'this', not 'super'.
}
get fooTests() {
return super.foo;
~~~
!!! error TS2855: Class field 'foo' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'foo' is defined by the superclass and must be accessed through 'this', not 'super'.
}
get justPropTests() {
return super.justProp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
superAccess.ts(9,24): error TS2576: Property 'S1' does not exist on type 'MyBase'. Did you mean to access the static member 'MyBase.S1' instead?
superAccess.ts(10,24): error TS2855: Class field 'S2' defined by the parent class is not accessible in the child class via super.
superAccess.ts(11,24): error TS2855: Class field 'f' defined by the parent class is not accessible in the child class via super.
superAccess.ts(10,24): error TS2855: Instance property 'S2' is defined by the superclass and must be accessed through 'this', not 'super'.
superAccess.ts(11,24): error TS2855: Instance property 'f' is defined by the superclass and must be accessed through 'this', not 'super'.


==== superAccess.ts (3 errors) ====
Expand All @@ -17,9 +17,9 @@ superAccess.ts(11,24): error TS2855: Class field 'f' defined by the parent class
!!! error TS2576: Property 'S1' does not exist on type 'MyBase'. Did you mean to access the static member 'MyBase.S1' instead?
var l4 = super.S2; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword
~~
!!! error TS2855: Class field 'S2' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'S2' is defined by the superclass and must be accessed through 'this', not 'super'.
var l5 = super.f(); // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword
~
!!! error TS2855: Class field 'f' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'f' is defined by the superclass and must be accessed through 'this', not 'super'.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
superAccessProtectedInstanceProperty.ts(9,22): error TS2855: Instance property 'roots' is defined by the superclass and must be accessed through 'this', not 'super'.


==== superAccessProtectedInstanceProperty.ts (1 errors) ====
// https://github.com/microsoft/TypeScript/issues/55883

export abstract class YaddaBase {
protected roots = "hi";
}

export class DerivedYadda extends YaddaBase {
public get rootTests() {
return super.roots;
~~~~~
!!! error TS2855: Instance property 'roots' is defined by the superclass and must be accessed through 'this', not 'super'.
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//// [tests/cases/compiler/superAccessProtectedInstanceProperty.ts] ////

//// [superAccessProtectedInstanceProperty.ts]
// https://github.com/microsoft/TypeScript/issues/55883

export abstract class YaddaBase {
protected roots = "hi";
}

export class DerivedYadda extends YaddaBase {
public get rootTests() {
return super.roots;
}
}


//// [superAccessProtectedInstanceProperty.js]
// https://github.com/microsoft/TypeScript/issues/55883
export class YaddaBase {
roots = "hi";
}
export class DerivedYadda extends YaddaBase {
get rootTests() {
return super.roots;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//// [tests/cases/compiler/superAccessProtectedInstanceProperty.ts] ////

=== superAccessProtectedInstanceProperty.ts ===
// https://github.com/microsoft/TypeScript/issues/55883

export abstract class YaddaBase {
>YaddaBase : Symbol(YaddaBase, Decl(superAccessProtectedInstanceProperty.ts, 0, 0))

protected roots = "hi";
>roots : Symbol(YaddaBase.roots, Decl(superAccessProtectedInstanceProperty.ts, 2, 33))
}

export class DerivedYadda extends YaddaBase {
>DerivedYadda : Symbol(DerivedYadda, Decl(superAccessProtectedInstanceProperty.ts, 4, 1))
>YaddaBase : Symbol(YaddaBase, Decl(superAccessProtectedInstanceProperty.ts, 0, 0))

public get rootTests() {
>rootTests : Symbol(DerivedYadda.rootTests, Decl(superAccessProtectedInstanceProperty.ts, 6, 45))

return super.roots;
>super.roots : Symbol(YaddaBase.roots, Decl(superAccessProtectedInstanceProperty.ts, 2, 33))
>super : Symbol(YaddaBase, Decl(superAccessProtectedInstanceProperty.ts, 0, 0))
>roots : Symbol(YaddaBase.roots, Decl(superAccessProtectedInstanceProperty.ts, 2, 33))
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//// [tests/cases/compiler/superAccessProtectedInstanceProperty.ts] ////

=== superAccessProtectedInstanceProperty.ts ===
// https://github.com/microsoft/TypeScript/issues/55883

export abstract class YaddaBase {
>YaddaBase : YaddaBase

protected roots = "hi";
>roots : string
>"hi" : "hi"
}

export class DerivedYadda extends YaddaBase {
>DerivedYadda : DerivedYadda
>YaddaBase : YaddaBase

public get rootTests() {
>rootTests : string

return super.roots;
>super.roots : string
>super : YaddaBase
>roots : string
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
superInLambdas.ts(47,49): error TS2855: Class field 'name' defined by the parent class is not accessible in the child class via super.
superInLambdas.ts(51,49): error TS2855: Class field 'name' defined by the parent class is not accessible in the child class via super.
superInLambdas.ts(47,49): error TS2855: Instance property 'name' is defined by the superclass and must be accessed through 'this', not 'super'.
superInLambdas.ts(51,49): error TS2855: Instance property 'name' is defined by the superclass and must be accessed through 'this', not 'super'.
superInLambdas.ts(61,34): error TS1034: 'super' must be followed by an argument list or member access.
superInLambdas.ts(65,34): error TS1034: 'super' must be followed by an argument list or member access.

Expand Down Expand Up @@ -53,13 +53,13 @@ superInLambdas.ts(65,34): error TS1034: 'super' must be followed by an argument
// super property in a nested lambda in a constructor
var superName = () => () => () => super.name;
~~~~
!!! error TS2855: Class field 'name' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'name' is defined by the superclass and must be accessed through 'this', not 'super'.
}
sayHello(): void {
// super property in a nested lambda in a method
var superName = () => () => () => super.name;
~~~~
!!! error TS2855: Class field 'name' defined by the parent class is not accessible in the child class via super.
!!! error TS2855: Instance property 'name' is defined by the superclass and must be accessed through 'this', not 'super'.
}
}

Expand Down
Loading