mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
c63111816c
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jakebailey <[email protected]>
131 lines
5.9 KiB
Plaintext
131 lines
5.9 KiB
Plaintext
//// [tests/cases/compiler/esDecoratorsPropertyAccessSameNameAsClass.ts] ////
|
|
|
|
=== esDecoratorsPropertyAccessSameNameAsClass.ts ===
|
|
export enum MyEnum {
|
|
>MyEnum : Symbol(MyEnum, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 0))
|
|
|
|
Foo = "FooValue",
|
|
>Foo : Symbol(MyEnum.Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 20))
|
|
|
|
Bar = "BarValue",
|
|
>Bar : Symbol(MyEnum.Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 1, 21))
|
|
}
|
|
|
|
function myDecorator(target: any, context: ClassDecoratorContext) {
|
|
>myDecorator : Symbol(myDecorator, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 3, 1))
|
|
>target : Symbol(target, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 5, 21))
|
|
>context : Symbol(context, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 5, 33))
|
|
>ClassDecoratorContext : Symbol(ClassDecoratorContext, Decl(lib.decorators.d.ts, --, --))
|
|
|
|
return target;
|
|
>target : Symbol(target, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 5, 21))
|
|
}
|
|
|
|
// ES decorators with enum member access sharing a class name
|
|
@myDecorator
|
|
>myDecorator : Symbol(myDecorator, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 3, 1))
|
|
|
|
export class Foo {
|
|
>Foo : Symbol(Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 7, 1))
|
|
|
|
type: MyEnum = MyEnum.Foo;
|
|
>type : Symbol(Foo.type, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 11, 18))
|
|
>MyEnum : Symbol(MyEnum, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 0))
|
|
>MyEnum.Foo : Symbol(MyEnum.Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 20))
|
|
>MyEnum : Symbol(MyEnum, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 0))
|
|
>Foo : Symbol(MyEnum.Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 20))
|
|
|
|
getType(): MyEnum {
|
|
>getType : Symbol(Foo.getType, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 12, 30))
|
|
>MyEnum : Symbol(MyEnum, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 0))
|
|
|
|
return this.type || MyEnum.Foo;
|
|
>this.type : Symbol(Foo.type, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 11, 18))
|
|
>this : Symbol(Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 7, 1))
|
|
>type : Symbol(Foo.type, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 11, 18))
|
|
>MyEnum.Foo : Symbol(MyEnum.Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 20))
|
|
>MyEnum : Symbol(MyEnum, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 0))
|
|
>Foo : Symbol(MyEnum.Foo, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 0, 20))
|
|
}
|
|
}
|
|
|
|
// Property access on objects
|
|
declare const obj: { Bar: string };
|
|
>obj : Symbol(obj, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 13))
|
|
>Bar : Symbol(Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 20))
|
|
|
|
@myDecorator
|
|
>myDecorator : Symbol(myDecorator, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 3, 1))
|
|
|
|
export class Bar {
|
|
>Bar : Symbol(Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 35))
|
|
|
|
prop = obj.Bar;
|
|
>prop : Symbol(Bar.prop, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 23, 18))
|
|
>obj.Bar : Symbol(Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 20))
|
|
>obj : Symbol(obj, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 13))
|
|
>Bar : Symbol(Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 20))
|
|
|
|
method() {
|
|
>method : Symbol(Bar.method, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 24, 19))
|
|
|
|
return obj.Bar;
|
|
>obj.Bar : Symbol(Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 20))
|
|
>obj : Symbol(obj, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 13))
|
|
>Bar : Symbol(Bar, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 20, 20))
|
|
}
|
|
}
|
|
|
|
// Static member of another class
|
|
class Other {
|
|
>Other : Symbol(Other, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 29, 1))
|
|
|
|
static Baz = 42;
|
|
>Baz : Symbol(Other.Baz, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 32, 13))
|
|
}
|
|
|
|
@myDecorator
|
|
>myDecorator : Symbol(myDecorator, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 3, 1))
|
|
|
|
export class Baz {
|
|
>Baz : Symbol(Baz, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 34, 1))
|
|
|
|
prop = Other.Baz;
|
|
>prop : Symbol(Baz.prop, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 37, 18))
|
|
>Other.Baz : Symbol(Other.Baz, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 32, 13))
|
|
>Other : Symbol(Other, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 29, 1))
|
|
>Baz : Symbol(Other.Baz, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 32, 13))
|
|
}
|
|
|
|
// ES decorators with static fields trigger class fields transformer aliases at target < ES2022.
|
|
// Property access names must not be substituted through the class fields transformer path.
|
|
declare const obj2: { Quux: number };
|
|
>obj2 : Symbol(obj2, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 13))
|
|
>Quux : Symbol(Quux, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 21))
|
|
|
|
@myDecorator
|
|
>myDecorator : Symbol(myDecorator, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 3, 1))
|
|
|
|
export class Quux {
|
|
>Quux : Symbol(Quux, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 37))
|
|
|
|
static count = 1;
|
|
>count : Symbol(Quux.count, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 46, 19))
|
|
|
|
prop = obj2.Quux;
|
|
>prop : Symbol(Quux.prop, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 47, 21))
|
|
>obj2.Quux : Symbol(Quux, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 21))
|
|
>obj2 : Symbol(obj2, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 13))
|
|
>Quux : Symbol(Quux, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 21))
|
|
|
|
method() {
|
|
>method : Symbol(Quux.method, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 48, 21))
|
|
|
|
return obj2.Quux;
|
|
>obj2.Quux : Symbol(Quux, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 21))
|
|
>obj2 : Symbol(obj2, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 13))
|
|
>Quux : Symbol(Quux, Decl(esDecoratorsPropertyAccessSameNameAsClass.ts, 43, 21))
|
|
}
|
|
}
|
|
|