TypeScript/tests/baselines/reference/privateNameDuplicateField.types
Titian Cernicova-Dragomir e638af7560
ES private class elements (#42458)
* Added support for private identifier methods.

* Added tests for private methods.

* Added check to only not allow private name method signatures in anything except classes.
Changes objects literal checking to not bail on first private name found in object literal.

* Added private accessors tests

* Transform private methods

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Rename shouldTransformPrivateFields

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Use a single WeakSet for brand-check

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add a test for using private methods in static field initializers

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add breaking checker test

Private methods inside class expressions should not error.

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add to instances once per-instance

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: evaluate receiver and rhs expressions before throwing on readonly assignment

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add a test for evaluating rhs before readonly assignment

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Transpile private accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: handle readonly/writeonly accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for private setter without a getter

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: getAllUnscopedEmitHelpers

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: better handling of duplicate names

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Fixed wrong error message for private methods in class expressions.

* change error message

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for async private methods with a higher target

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: setter assignment returns rhs value

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for setter assignment return value

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: handle duplicate accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add tests for duplicate accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* docs: add missing parameter docs

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Fixed failing test.

* baseline-accept: ordering changes

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: attach weakSetName to property declaration

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for nested private methods

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test with any

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Added support for static private fields accessors and methods.

* Added error message for private identifiers used with static decorators. There is no spec to go with this behavior as of yet.

* Fixed emit static bug that used private names outside of classes for initialization in esnext. Fixed issue where nested privates produce incorrect brand check.

* Added tests for private static fields methods and accessors.

* Fixed error messages and tests after merge.

* Accept new baseline.

* Improved duplicate identifier checks for static private class elements.

* Added error when using initializers with private static fields when useDefineForClassFields is not specified and target is esnext.

* Fixed code review issues.

* Removed semantically wrong emit on `useDefineForClassFields:true` with `target:esnext`

* Changed emit for uninitialized private static fields.

* Added runtime error in helper if a static private field is accessed before it was declared.

* Fixed code review comments for private identifier static class elements.

* add debug.assertNever for unknown node type (#53)

* Fixed code review issues.

* Fixed code review issues for private class elements.

* Fixes class shadowing when checking access to a private static class element.

* fix private methods/accessors in class expr inside a loop

* collapse switch case

* fix class name

* simplify getPrivateMethodsAndAccessors

* remove findPreviousAccessorInfo

* lazily create weakSetName identifier

* do not allocate a node if not needed in visitMehodDeclaration (#55)

* Removed all the emit helpers for private identifier methods accessors and modified the existing helpers for get and set fields to do the same job.

* Simplified emit for private identifier class elements.

* do not clone the receiver (#57)

* leave bad code in for #constructor and duplicate private names (#58)

* Added check for WeakSet collision.

* Added error for using a set only accessor.

* update keyof tests and ?? (#62)

* replace ?? with ||

* update keyof tests

* fix emit helpers comments

* produce an error if private field helpers are not up to date

* add tests

* fix setter-only compound assignment

* fix tests

* fix duplicated trailing comments (#64)

* clear receiver pos and setTextRange on helper calls

Co-authored-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
2021-03-24 18:15:50 -07:00

833 lines
15 KiB
Plaintext

=== tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts ===
function Field() {
>Field : () => void
// Error
class A_Field_Field {
>A_Field_Field : A_Field_Field
#foo = "foo";
>#foo : string
>"foo" : "foo"
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_Field_Method {
>A_Field_Method : A_Field_Method
#foo = "foo";
>#foo : string
>"foo" : "foo"
#foo() { }
>#foo : () => void
}
// Error
class A_Field_Getter {
>A_Field_Getter : A_Field_Getter
#foo = "foo";
>#foo : string
>"foo" : "foo"
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Field_Setter {
>A_Field_Setter : A_Field_Setter
#foo = "foo";
>#foo : string
>"foo" : "foo"
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_Field_StaticField {
>A_Field_StaticField : A_Field_StaticField
#foo = "foo";
>#foo : string
>"foo" : "foo"
static #foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_Field_StaticMethod {
>A_Field_StaticMethod : A_Field_StaticMethod
#foo = "foo";
>#foo : string
>"foo" : "foo"
static #foo() { }
>#foo : () => void
}
// Error
class A_Field_StaticGetter {
>A_Field_StaticGetter : A_Field_StaticGetter
#foo = "foo";
>#foo : string
>"foo" : "foo"
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Field_StaticSetter {
>A_Field_StaticSetter : A_Field_StaticSetter
#foo = "foo";
>#foo : string
>"foo" : "foo"
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function Method() {
>Method : () => void
// Error
class A_Method_Field {
>A_Method_Field : A_Method_Field
#foo() { }
>#foo : () => void
#foo = "foo";
>#foo : () => void
>"foo" : "foo"
}
// Error
class A_Method_Method {
>A_Method_Method : A_Method_Method
#foo() { }
>#foo : () => void
#foo() { }
>#foo : () => void
}
// Error
class A_Method_Getter {
>A_Method_Getter : A_Method_Getter
#foo() { }
>#foo : () => void
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Method_Setter {
>A_Method_Setter : A_Method_Setter
#foo() { }
>#foo : () => void
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_Method_StaticField {
>A_Method_StaticField : A_Method_StaticField
#foo() { }
>#foo : () => void
static #foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_Method_StaticMethod {
>A_Method_StaticMethod : A_Method_StaticMethod
#foo() { }
>#foo : () => void
static #foo() { }
>#foo : () => void
}
// Error
class A_Method_StaticGetter {
>A_Method_StaticGetter : A_Method_StaticGetter
#foo() { }
>#foo : () => void
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Method_StaticSetter {
>A_Method_StaticSetter : A_Method_StaticSetter
#foo() { }
>#foo : () => void
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function Getter() {
>Getter : () => void
// Error
class A_Getter_Field {
>A_Getter_Field : A_Getter_Field
get #foo() { return ""}
>#foo : string
>"" : ""
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_Getter_Method {
>A_Getter_Method : A_Getter_Method
get #foo() { return ""}
>#foo : string
>"" : ""
#foo() { }
>#foo : () => void
}
// Error
class A_Getter_Getter {
>A_Getter_Getter : A_Getter_Getter
get #foo() { return ""}
>#foo : string
>"" : ""
get #foo() { return ""}
>#foo : string
>"" : ""
}
//OK
class A_Getter_Setter {
>A_Getter_Setter : A_Getter_Setter
get #foo() { return ""}
>#foo : string
>"" : ""
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_Getter_StaticField {
>A_Getter_StaticField : A_Getter_StaticField
get #foo() { return ""}
>#foo : string
>"" : ""
static #foo() { }
>#foo : () => void
}
// Error
class A_Getter_StaticMethod {
>A_Getter_StaticMethod : A_Getter_StaticMethod
get #foo() { return ""}
>#foo : string
>"" : ""
static #foo() { }
>#foo : () => void
}
// Error
class A_Getter_StaticGetter {
>A_Getter_StaticGetter : A_Getter_StaticGetter
get #foo() { return ""}
>#foo : string
>"" : ""
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Getter_StaticSetter {
>A_Getter_StaticSetter : A_Getter_StaticSetter
get #foo() { return ""}
>#foo : string
>"" : ""
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function Setter() {
>Setter : () => void
// Error
class A_Setter_Field {
>A_Setter_Field : A_Setter_Field
set #foo(value: string) { }
>#foo : string
>value : string
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_Setter_Method {
>A_Setter_Method : A_Setter_Method
set #foo(value: string) { }
>#foo : string
>value : string
#foo() { }
>#foo : () => void
}
// OK
class A_Setter_Getter {
>A_Setter_Getter : A_Setter_Getter
set #foo(value: string) { }
>#foo : string
>value : string
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Setter_Setter {
>A_Setter_Setter : A_Setter_Setter
set #foo(value: string) { }
>#foo : string
>value : string
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_Setter_StaticField {
>A_Setter_StaticField : A_Setter_StaticField
set #foo(value: string) { }
>#foo : string
>value : string
static #foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_Setter_StaticMethod {
>A_Setter_StaticMethod : A_Setter_StaticMethod
set #foo(value: string) { }
>#foo : string
>value : string
static #foo() { }
>#foo : () => void
}
// Error
class A_Setter_StaticGetter {
>A_Setter_StaticGetter : A_Setter_StaticGetter
set #foo(value: string) { }
>#foo : string
>value : string
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_Setter_StaticSetter {
>A_Setter_StaticSetter : A_Setter_StaticSetter
set #foo(value: string) { }
>#foo : string
>value : string
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function StaticField() {
>StaticField : () => void
// Error
class A_StaticField_Field {
>A_StaticField_Field : A_StaticField_Field
static #foo = "foo";
>#foo : string
>"foo" : "foo"
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_StaticField_Method {
>A_StaticField_Method : A_StaticField_Method
static #foo = "foo";
>#foo : string
>"foo" : "foo"
#foo() { }
>#foo : () => void
}
// Error
class A_StaticField_Getter {
>A_StaticField_Getter : A_StaticField_Getter
static #foo = "foo";
>#foo : string
>"foo" : "foo"
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticField_Setter {
>A_StaticField_Setter : A_StaticField_Setter
static #foo = "foo";
>#foo : string
>"foo" : "foo"
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_StaticField_StaticField {
>A_StaticField_StaticField : A_StaticField_StaticField
static #foo = "foo";
>#foo : string
>"foo" : "foo"
static #foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_StaticField_StaticMethod {
>A_StaticField_StaticMethod : A_StaticField_StaticMethod
static #foo = "foo";
>#foo : string
>"foo" : "foo"
static #foo() { }
>#foo : () => void
}
// Error
class A_StaticField_StaticGetter {
>A_StaticField_StaticGetter : A_StaticField_StaticGetter
static #foo = "foo";
>#foo : string
>"foo" : "foo"
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticField_StaticSetter {
>A_StaticField_StaticSetter : A_StaticField_StaticSetter
static #foo = "foo";
>#foo : string
>"foo" : "foo"
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function StaticMethod() {
>StaticMethod : () => void
// Error
class A_StaticMethod_Field {
>A_StaticMethod_Field : A_StaticMethod_Field
static #foo() { }
>#foo : () => void
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_StaticMethod_Method {
>A_StaticMethod_Method : A_StaticMethod_Method
static #foo() { }
>#foo : () => void
#foo() { }
>#foo : () => void
}
// Error
class A_StaticMethod_Getter {
>A_StaticMethod_Getter : A_StaticMethod_Getter
static #foo() { }
>#foo : () => void
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticMethod_Setter {
>A_StaticMethod_Setter : A_StaticMethod_Setter
static #foo() { }
>#foo : () => void
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_StaticMethod_StaticField {
>A_StaticMethod_StaticField : A_StaticMethod_StaticField
static #foo() { }
>#foo : () => void
static #foo = "foo";
>#foo : () => void
>"foo" : "foo"
}
// Error
class A_StaticMethod_StaticMethod {
>A_StaticMethod_StaticMethod : A_StaticMethod_StaticMethod
static #foo() { }
>#foo : () => void
static #foo() { }
>#foo : () => void
}
// Error
class A_StaticMethod_StaticGetter {
>A_StaticMethod_StaticGetter : A_StaticMethod_StaticGetter
static #foo() { }
>#foo : () => void
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticMethod_StaticSetter {
>A_StaticMethod_StaticSetter : A_StaticMethod_StaticSetter
static #foo() { }
>#foo : () => void
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function StaticGetter() {
>StaticGetter : () => void
// Error
class A_StaticGetter_Field {
>A_StaticGetter_Field : A_StaticGetter_Field
static get #foo() { return ""}
>#foo : string
>"" : ""
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_StaticGetter_Method {
>A_StaticGetter_Method : A_StaticGetter_Method
static get #foo() { return ""}
>#foo : string
>"" : ""
#foo() { }
>#foo : () => void
}
// Error
class A_StaticGetter_Getter {
>A_StaticGetter_Getter : A_StaticGetter_Getter
static get #foo() { return ""}
>#foo : string
>"" : ""
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticGetter_Setter {
>A_StaticGetter_Setter : A_StaticGetter_Setter
static get #foo() { return ""}
>#foo : string
>"" : ""
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_StaticGetter_StaticField {
>A_StaticGetter_StaticField : A_StaticGetter_StaticField
static get #foo() { return ""}
>#foo : string
>"" : ""
static #foo() { }
>#foo : () => void
}
// Error
class A_StaticGetter_StaticMethod {
>A_StaticGetter_StaticMethod : A_StaticGetter_StaticMethod
static get #foo() { return ""}
>#foo : string
>"" : ""
static #foo() { }
>#foo : () => void
}
// Error
class A_StaticGetter_StaticGetter {
>A_StaticGetter_StaticGetter : A_StaticGetter_StaticGetter
static get #foo() { return ""}
>#foo : string
>"" : ""
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// OK
class A_StaticGetter_StaticSetter {
>A_StaticGetter_StaticSetter : A_StaticGetter_StaticSetter
static get #foo() { return ""}
>#foo : string
>"" : ""
static set #foo(value: string) { }
>#foo : string
>value : string
}
}
function StaticSetter() {
>StaticSetter : () => void
// Error
class A_StaticSetter_Field {
>A_StaticSetter_Field : A_StaticSetter_Field
static set #foo(value: string) { }
>#foo : string
>value : string
#foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_StaticSetter_Method {
>A_StaticSetter_Method : A_StaticSetter_Method
static set #foo(value: string) { }
>#foo : string
>value : string
#foo() { }
>#foo : () => void
}
// Error
class A_StaticSetter_Getter {
>A_StaticSetter_Getter : A_StaticSetter_Getter
static set #foo(value: string) { }
>#foo : string
>value : string
get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticSetter_Setter {
>A_StaticSetter_Setter : A_StaticSetter_Setter
static set #foo(value: string) { }
>#foo : string
>value : string
set #foo(value: string) { }
>#foo : string
>value : string
}
// Error
class A_StaticSetter_StaticField {
>A_StaticSetter_StaticField : A_StaticSetter_StaticField
static set #foo(value: string) { }
>#foo : string
>value : string
static #foo = "foo";
>#foo : string
>"foo" : "foo"
}
// Error
class A_StaticSetter_StaticMethod {
>A_StaticSetter_StaticMethod : A_StaticSetter_StaticMethod
static set #foo(value: string) { }
>#foo : string
>value : string
static #foo() { }
>#foo : () => void
}
// OK
class A_StaticSetter_StaticGetter {
>A_StaticSetter_StaticGetter : A_StaticSetter_StaticGetter
static set #foo(value: string) { }
>#foo : string
>value : string
static get #foo() { return ""}
>#foo : string
>"" : ""
}
// Error
class A_StaticSetter_StaticSetter {
>A_StaticSetter_StaticSetter : A_StaticSetter_StaticSetter
static set #foo(value: string) { }
>#foo : string
>value : string
static set #foo(value: string) { }
>#foo : string
>value : string
}
}