-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Keep accessors as accessors in emitted anonymous class declarations #60853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jakebailey
merged 7 commits into
microsoft:main
from
Andarist:keep-accessors-as-accessors-on-emitted-anonymous-class-declarations
Jun 30, 2025
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3fe512a
Keep accessors as accessors in emitted anonymous class declarations
Andarist 1baa828
Propagate accessor flags in intersected properties
Andarist 161e1ca
fixed a thing
Andarist e38b30d
Merge remote-tracking branch 'origin/main' into keep-accessors-as-acc…
Andarist d29a82a
add extra test case
Andarist b43f9dd
add extra test case
Andarist 4372016
split comment into multiple lines
Andarist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
66 changes: 66 additions & 0 deletions
66
tests/baselines/reference/anonymousClassAccessorsDeclarationEmit1.js
This file contains hidden or 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,66 @@ | ||
| //// [tests/cases/conformance/declarationEmit/anonymousClassAccessorsDeclarationEmit1.ts] //// | ||
|
|
||
| //// [anonymousClassAccessorsDeclarationEmit1.ts] | ||
| export abstract class Base { | ||
| accessor a = 1; | ||
| } | ||
|
|
||
| export function middle(Super = Base) { | ||
| abstract class Middle extends Super {} | ||
| return Middle; | ||
| } | ||
|
|
||
| class A { | ||
| constructor(...args: any[]) {} | ||
| } | ||
|
|
||
| export function Mixin<T extends typeof A>(Super: T) { | ||
| return class B extends Super { | ||
| get myName(): string { | ||
| return "B"; | ||
| } | ||
| set myName(arg: string) {} | ||
| }; | ||
| } | ||
|
|
||
|
|
||
| //// [anonymousClassAccessorsDeclarationEmit1.js] | ||
| export class Base { | ||
| accessor a = 1; | ||
| } | ||
| export function middle(Super = Base) { | ||
| class Middle extends Super { | ||
| } | ||
| return Middle; | ||
| } | ||
| class A { | ||
| constructor(...args) { } | ||
| } | ||
| export function Mixin(Super) { | ||
| return class B extends Super { | ||
| get myName() { | ||
| return "B"; | ||
| } | ||
| set myName(arg) { } | ||
| }; | ||
| } | ||
|
|
||
|
|
||
| //// [anonymousClassAccessorsDeclarationEmit1.d.ts] | ||
| export declare abstract class Base { | ||
| accessor a: number; | ||
| } | ||
| export declare function middle(Super?: typeof Base): abstract new () => { | ||
| get a(): number; | ||
| set a(arg: number); | ||
| }; | ||
| declare class A { | ||
| constructor(...args: any[]); | ||
| } | ||
| export declare function Mixin<T extends typeof A>(Super: T): { | ||
| new (...args: any[]): { | ||
| get myName(): string; | ||
| set myName(arg: string); | ||
| }; | ||
| } & T; | ||
| export {}; |
53 changes: 53 additions & 0 deletions
53
tests/baselines/reference/anonymousClassAccessorsDeclarationEmit1.symbols
This file contains hidden or 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,53 @@ | ||
| //// [tests/cases/conformance/declarationEmit/anonymousClassAccessorsDeclarationEmit1.ts] //// | ||
|
|
||
| === anonymousClassAccessorsDeclarationEmit1.ts === | ||
| export abstract class Base { | ||
| >Base : Symbol(Base, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 0, 0)) | ||
|
|
||
| accessor a = 1; | ||
| >a : Symbol(Base.a, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 0, 28)) | ||
| } | ||
|
|
||
| export function middle(Super = Base) { | ||
| >middle : Symbol(middle, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 2, 1)) | ||
| >Super : Symbol(Super, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 4, 23)) | ||
| >Base : Symbol(Base, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 0, 0)) | ||
|
|
||
| abstract class Middle extends Super {} | ||
| >Middle : Symbol(Middle, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 4, 38)) | ||
| >Super : Symbol(Super, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 4, 23)) | ||
|
|
||
| return Middle; | ||
| >Middle : Symbol(Middle, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 4, 38)) | ||
| } | ||
|
|
||
| class A { | ||
| >A : Symbol(A, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 7, 1)) | ||
|
|
||
| constructor(...args: any[]) {} | ||
| >args : Symbol(args, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 10, 14)) | ||
| } | ||
|
|
||
| export function Mixin<T extends typeof A>(Super: T) { | ||
| >Mixin : Symbol(Mixin, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 11, 1)) | ||
| >T : Symbol(T, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 13, 22)) | ||
| >A : Symbol(A, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 7, 1)) | ||
| >Super : Symbol(Super, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 13, 42)) | ||
| >T : Symbol(T, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 13, 22)) | ||
|
|
||
| return class B extends Super { | ||
| >B : Symbol(B, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 14, 8)) | ||
| >Super : Symbol(Super, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 13, 42)) | ||
|
|
||
| get myName(): string { | ||
| >myName : Symbol(B.myName, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 14, 32), Decl(anonymousClassAccessorsDeclarationEmit1.ts, 17, 5)) | ||
|
|
||
| return "B"; | ||
| } | ||
| set myName(arg: string) {} | ||
| >myName : Symbol(B.myName, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 14, 32), Decl(anonymousClassAccessorsDeclarationEmit1.ts, 17, 5)) | ||
| >arg : Symbol(arg, Decl(anonymousClassAccessorsDeclarationEmit1.ts, 18, 15)) | ||
|
|
||
| }; | ||
| } | ||
|
|
75 changes: 75 additions & 0 deletions
75
tests/baselines/reference/anonymousClassAccessorsDeclarationEmit1.types
This file contains hidden or 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,75 @@ | ||
| //// [tests/cases/conformance/declarationEmit/anonymousClassAccessorsDeclarationEmit1.ts] //// | ||
|
|
||
| === anonymousClassAccessorsDeclarationEmit1.ts === | ||
| export abstract class Base { | ||
| >Base : Base | ||
| > : ^^^^ | ||
|
|
||
| accessor a = 1; | ||
| >a : number | ||
| > : ^^^^^^ | ||
| >1 : 1 | ||
| > : ^ | ||
| } | ||
|
|
||
| export function middle(Super = Base) { | ||
| >middle : (Super?: typeof Base) => typeof Middle | ||
| > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| >Super : typeof Base | ||
| > : ^^^^^^^^^^^ | ||
| >Base : typeof Base | ||
| > : ^^^^^^^^^^^ | ||
|
|
||
| abstract class Middle extends Super {} | ||
| >Middle : Middle | ||
| > : ^^^^^^ | ||
| >Super : Base | ||
| > : ^^^^ | ||
|
|
||
| return Middle; | ||
| >Middle : typeof Middle | ||
| > : ^^^^^^^^^^^^^ | ||
| } | ||
|
|
||
| class A { | ||
| >A : A | ||
| > : ^ | ||
|
|
||
| constructor(...args: any[]) {} | ||
| >args : any[] | ||
| > : ^^^^^ | ||
| } | ||
|
|
||
| export function Mixin<T extends typeof A>(Super: T) { | ||
| >Mixin : <T extends typeof A>(Super: T) => { new (...args: any[]): B; prototype: Mixin<any>.B; } & T | ||
| > : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| >A : typeof A | ||
| > : ^^^^^^^^ | ||
| >Super : T | ||
| > : ^ | ||
|
|
||
| return class B extends Super { | ||
| >class B extends Super { get myName(): string { return "B"; } set myName(arg: string) {} } : { new (...args: any[]): B; prototype: Mixin<any>.B; } & T | ||
| > : ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| >B : { new (...args: any[]): B; prototype: Mixin<any>.B; } & T | ||
| > : ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| >Super : A | ||
| > : ^ | ||
|
|
||
| get myName(): string { | ||
| >myName : string | ||
| > : ^^^^^^ | ||
|
|
||
| return "B"; | ||
| >"B" : "B" | ||
| > : ^^^ | ||
| } | ||
| set myName(arg: string) {} | ||
| >myName : string | ||
| > : ^^^^^^ | ||
| >arg : string | ||
| > : ^^^^^^ | ||
|
|
||
| }; | ||
| } | ||
|
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.