From 9735ea3c4d7c53cf06ad8e0ca3c80cd2e6b2965a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sun, 5 Oct 2025 00:27:05 +0200 Subject: [PATCH] Port "Keep accessors as accessors in emitted anonymous class declarations" --- internal/checker/checker.go | 26 ++++++--- internal/checker/nodebuilderimpl.go | 55 +++++++++++++------ ...ionEmitGenericTypeParamerSerialization3.js | 6 +- ...itGenericTypeParamerSerialization3.js.diff | 18 ------ ...anonymousClassAccessorsDeclarationEmit1.js | 6 +- ...mousClassAccessorsDeclarationEmit1.js.diff | 21 ------- .../submodule/conformance/autoAccessor8.js | 6 +- .../conformance/autoAccessor8.js.diff | 14 ----- .../conformance/mixinAccessors1.errors.txt | 27 --------- .../mixinAccessors1.errors.txt.diff | 31 ----------- .../submodule/conformance/mixinAccessors1.js | 4 +- .../conformance/mixinAccessors1.js.diff | 20 +------ .../conformance/mixinAccessors2.errors.txt | 20 ------- .../mixinAccessors2.errors.txt.diff | 24 -------- .../submodule/conformance/mixinAccessors2.js | 6 +- .../conformance/mixinAccessors2.js.diff | 22 +------- .../submodule/conformance/mixinAccessors3.js | 4 +- .../conformance/mixinAccessors3.js.diff | 20 +------ .../conformance/mixinAccessors4.errors.txt | 29 ---------- .../mixinAccessors4.errors.txt.diff | 33 ----------- .../submodule/conformance/mixinAccessors4.js | 4 +- .../conformance/mixinAccessors4.js.diff | 17 +----- .../conformance/mixinAccessors5.errors.txt | 29 ---------- .../mixinAccessors5.errors.txt.diff | 33 ----------- 24 files changed, 83 insertions(+), 392 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/autoAccessor8.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 42f3851a61..f7802b6fc2 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -15705,14 +15705,14 @@ func (c *Checker) getWriteTypeOfSymbolWithDeferredType(symbol *ast.Symbol) *Type // properties deriving from set accessors will either pre-compute or defer the union or // intersection of the writeTypes of their constituents. func (c *Checker) getWriteTypeOfSymbol(symbol *ast.Symbol) *Type { - if symbol.Flags&ast.SymbolFlagsProperty != 0 { - if symbol.CheckFlags&ast.CheckFlagsSyntheticProperty != 0 { - if symbol.CheckFlags&ast.CheckFlagsDeferredType != 0 { - return c.getWriteTypeOfSymbolWithDeferredType(symbol) - } - links := c.valueSymbolLinks.Get(symbol) - return core.OrElse(links.writeType, links.resolvedType) + if symbol.CheckFlags&ast.CheckFlagsSyntheticProperty != 0 { + if symbol.CheckFlags&ast.CheckFlagsDeferredType != 0 { + return c.getWriteTypeOfSymbolWithDeferredType(symbol) } + links := c.valueSymbolLinks.Get(symbol) + return core.OrElse(links.writeType, links.resolvedType) + } + if symbol.Flags&ast.SymbolFlagsProperty != 0 { return c.removeMissingType(c.getTypeOfSymbol(symbol), symbol.Flags&ast.SymbolFlagsOptional != 0) } if symbol.Flags&ast.SymbolFlagsAccessor != 0 { @@ -20603,6 +20603,7 @@ func (c *Checker) getUnionOrIntersectionProperty(t *Type, name string, skipObjec } func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name string, skipObjectFunctionPropertyAugment bool) *ast.Symbol { + propFlags := ast.SymbolFlagsNone var singleProp *ast.Symbol var propSet collections.OrderedSet[*ast.Symbol] var indexTypes []*Type @@ -20632,6 +20633,7 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s } if singleProp == nil { singleProp = prop + propFlags = core.OrElse(prop.Flags&ast.SymbolFlagsAccessor, ast.SymbolFlagsProperty) } else if prop != singleProp { isInstantiation := c.getTargetSymbol(prop) == c.getTargetSymbol(singleProp) // If the symbols are instances of one another with identical types - consider the symbols @@ -20648,6 +20650,13 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s } propSet.Add(prop) } + // classes created by mixins are represented as intersections + // and overriding a property in a derived class redefines it completely at runtime + // so a get accessor can't be merged with a set accessor in a base class, + // for that reason the accessor flags are only used when they are the same in all constituents + if propFlags&ast.SymbolFlagsAccessor != 0 && (prop.Flags&ast.SymbolFlagsAccessor != (propFlags & ast.SymbolFlagsAccessor)) { + propFlags = (propFlags &^ ast.SymbolFlagsAccessor) | ast.SymbolFlagsProperty + } } if isUnion && c.isReadonlySymbol(prop) { checkFlags |= ast.CheckFlagsReadonly @@ -20675,6 +20684,7 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s indexInfo = c.getApplicableIndexInfoForName(t, name) } if indexInfo != nil { + propFlags = propFlags&^ast.SymbolFlagsAccessor | ast.SymbolFlagsProperty checkFlags |= ast.CheckFlagsWritePartial | (core.IfElse(indexInfo.isReadonly, ast.CheckFlagsReadonly, 0)) if isTupleType(t) { indexType := c.getRestTypeOfTupleType(t) @@ -20767,7 +20777,7 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s propTypes = append(propTypes, t) } propTypes = append(propTypes, indexTypes...) - result := c.newSymbolEx(ast.SymbolFlagsProperty|optionalFlag, name, checkFlags|syntheticFlag) + result := c.newSymbolEx(propFlags|optionalFlag, name, checkFlags|syntheticFlag) result.Declarations = declarations if !hasNonUniformValueDeclaration && firstValueDeclaration != nil { result.ValueDeclaration = firstValueDeclaration diff --git a/internal/checker/nodebuilderimpl.go b/internal/checker/nodebuilderimpl.go index 31e79c8bde..ab8e12a313 100644 --- a/internal/checker/nodebuilderimpl.go +++ b/internal/checker/nodebuilderimpl.go @@ -2214,22 +2214,45 @@ func (b *nodeBuilderImpl) addPropertyToElementList(propertySymbol *ast.Symbol, t if propertySymbol.Flags&ast.SymbolFlagsAccessor != 0 { writeType := b.ch.getWriteTypeOfSymbol(propertySymbol) - if propertyType != writeType && !b.ch.isErrorType(propertyType) && !b.ch.isErrorType(writeType) { - getterDeclaration := ast.GetDeclarationOfKind(propertySymbol, ast.KindGetAccessor) - getterSignature := b.ch.getSignatureFromDeclaration(getterDeclaration) - getter := b.signatureToSignatureDeclarationHelper(getterSignature, ast.KindGetAccessor, &SignatureToSignatureDeclarationOptions{ - name: propertyName, - }) - b.setCommentRange(getter, getterDeclaration) - typeElements = append(typeElements, getter) - setterDeclaration := ast.GetDeclarationOfKind(propertySymbol, ast.KindSetAccessor) - setterSignature := b.ch.getSignatureFromDeclaration(setterDeclaration) - setter := b.signatureToSignatureDeclarationHelper(setterSignature, ast.KindSetAccessor, &SignatureToSignatureDeclarationOptions{ - name: propertyName, - }) - b.setCommentRange(setter, setterDeclaration) - typeElements = append(typeElements, setter) - return typeElements + if !b.ch.isErrorType(propertyType) && !b.ch.isErrorType(writeType) { + propDeclaration := ast.GetDeclarationOfKind(propertySymbol, ast.KindPropertyDeclaration) + if propertyType != writeType || propertySymbol.Parent.Flags&ast.SymbolFlagsClass != 0 && propDeclaration == nil { + if getterDeclaration := ast.GetDeclarationOfKind(propertySymbol, ast.KindGetAccessor); getterDeclaration != nil { + getterSignature := b.ch.getSignatureFromDeclaration(getterDeclaration) + getter := b.signatureToSignatureDeclarationHelper(getterSignature, ast.KindGetAccessor, &SignatureToSignatureDeclarationOptions{ + name: propertyName, + }) + b.setCommentRange(getter, getterDeclaration) + typeElements = append(typeElements, getter) + } + if setterDeclaration := ast.GetDeclarationOfKind(propertySymbol, ast.KindSetAccessor); setterDeclaration != nil { + setterSignature := b.ch.getSignatureFromDeclaration(setterDeclaration) + setter := b.signatureToSignatureDeclarationHelper(setterSignature, ast.KindSetAccessor, &SignatureToSignatureDeclarationOptions{ + name: propertyName, + }) + b.setCommentRange(setter, setterDeclaration) + typeElements = append(typeElements, setter) + } + return typeElements + } else if propertySymbol.Parent.Flags&ast.SymbolFlagsClass != 0 && propDeclaration != nil && core.Find(propDeclaration.ModifierNodes(), func(m *ast.Node) bool { + return m.Kind == ast.KindAccessorKeyword + }) != nil { + fakeGetterSignature := b.ch.newSignature(SignatureFlagsNone, nil, nil, nil, nil, propertyType, nil, 0) + fakeGetterDeclaration := b.signatureToSignatureDeclarationHelper(fakeGetterSignature, ast.KindGetAccessor, &SignatureToSignatureDeclarationOptions{ + name: propertyName, + }) + b.setCommentRange(fakeGetterDeclaration, propDeclaration) + typeElements = append(typeElements, fakeGetterDeclaration) + + setterParam := b.ch.newSymbol(ast.SymbolFlagsFunctionScopedVariable, "arg") + b.ch.valueSymbolLinks.Get(setterParam).resolvedType = writeType + fakeSetterSignature := b.ch.newSignature(SignatureFlagsNone, nil, nil, nil, []*ast.Symbol{setterParam}, b.ch.voidType, nil, 0) + fakeSetterDeclaration := b.signatureToSignatureDeclarationHelper(fakeSetterSignature, ast.KindSetAccessor, &SignatureToSignatureDeclarationOptions{ + name: propertyName, + }) + typeElements = append(typeElements, fakeSetterDeclaration) + return typeElements + } } } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js b/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js index 519c94d037..172ee40b11 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js @@ -36,11 +36,13 @@ export const Cls = wrapper("test"); //// [declarationEmitGenericTypeParamerSerialization3.d.ts] export declare function wrapper(value: T): { new (): { - name: T; + get name(): T; + set name(arg: T); }; }; export declare const Cls: { new (): { - name: string; + get name(): string; + set name(arg: string); }; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js.diff deleted file mode 100644 index 8cb65f8e28..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitGenericTypeParamerSerialization3.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.declarationEmitGenericTypeParamerSerialization3.js -+++ new.declarationEmitGenericTypeParamerSerialization3.js -@@= skipped -35, +35 lines =@@ - //// [declarationEmitGenericTypeParamerSerialization3.d.ts] - export declare function wrapper(value: T): { - new (): { -- get name(): T; -- set name(arg: T); -+ name: T; - }; - }; - export declare const Cls: { - new (): { -- get name(): string; -- set name(arg: string); -+ name: string; - }; - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js b/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js index fbea283f11..97be26cb3b 100644 --- a/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js +++ b/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js @@ -51,14 +51,16 @@ export declare abstract class Base { accessor a: number; } export declare function middle(Super?: typeof Base): abstract new () => { - a: number; + get a(): number; + set a(arg: number); }; declare class A { constructor(...args: any[]); } export declare function Mixin(Super: T): { new (...args: any[]): { - myName: string; + get myName(): string; + set myName(arg: string); }; } & T; export {}; diff --git a/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js.diff b/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js.diff deleted file mode 100644 index 4ea410aa81..0000000000 --- a/testdata/baselines/reference/submodule/conformance/anonymousClassAccessorsDeclarationEmit1.js.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.anonymousClassAccessorsDeclarationEmit1.js -+++ new.anonymousClassAccessorsDeclarationEmit1.js -@@= skipped -50, +50 lines =@@ - accessor a: number; - } - export declare function middle(Super?: typeof Base): abstract new () => { -- get a(): number; -- set a(arg: number); -+ a: number; - }; - declare class A { - constructor(...args: any[]); - } - export declare function Mixin(Super: T): { - new (...args: any[]): { -- get myName(): string; -- set myName(arg: string); -+ myName: string; - }; - } & T; - export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor8.js b/testdata/baselines/reference/submodule/conformance/autoAccessor8.js index cb2fb8c393..3203876cec 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor8.js +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor8.js @@ -45,7 +45,9 @@ declare class C2 { } declare function f(): { new (): { - a: any; + get a(): any; + set a(arg: any); }; - b: any; + get b(): any; + set b(arg: any); }; diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor8.js.diff b/testdata/baselines/reference/submodule/conformance/autoAccessor8.js.diff deleted file mode 100644 index c8d11ac1fc..0000000000 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor8.js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.autoAccessor8.js -+++ new.autoAccessor8.js -@@= skipped -44, +44 lines =@@ - } - declare function f(): { - new (): { -- get a(): any; -- set a(arg: any); -+ a: any; - }; -- get b(): any; -- set b(arg: any); -+ b: any; - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt b/testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt deleted file mode 100644 index 4c13cf3c6b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -mixinAccessors1.ts(18,7): error TS2611: 'validationTarget' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. - - -==== mixinAccessors1.ts (1 errors) ==== - // https://github.com/microsoft/TypeScript/issues/58790 - - function mixin(superclass: T) { - return class extends superclass { - get validationTarget(): HTMLElement { - return document.createElement("input"); - } - }; - } - - class BaseClass { - get validationTarget(): HTMLElement { - return document.createElement("div"); - } - } - - class MyClass extends mixin(BaseClass) { - get validationTarget(): HTMLElement { - ~~~~~~~~~~~~~~~~ -!!! error TS2611: 'validationTarget' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. - return document.createElement("select"); - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt.diff deleted file mode 100644 index 1dada5111f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.mixinAccessors1.errors.txt -+++ new.mixinAccessors1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mixinAccessors1.ts(18,7): error TS2611: 'validationTarget' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. -+ -+ -+==== mixinAccessors1.ts (1 errors) ==== -+ // https://github.com/microsoft/TypeScript/issues/58790 -+ -+ function mixin(superclass: T) { -+ return class extends superclass { -+ get validationTarget(): HTMLElement { -+ return document.createElement("input"); -+ } -+ }; -+ } -+ -+ class BaseClass { -+ get validationTarget(): HTMLElement { -+ return document.createElement("div"); -+ } -+ } -+ -+ class MyClass extends mixin(BaseClass) { -+ get validationTarget(): HTMLElement { -+ ~~~~~~~~~~~~~~~~ -+!!! error TS2611: 'validationTarget' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. -+ return document.createElement("select"); -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js b/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js index a79d463fcd..9d17437369 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js @@ -49,7 +49,7 @@ declare function mixin(superclass: T): { new (...args: any[]): { - readonly validationTarget: HTMLElement; + get validationTarget(): HTMLElement; }; } & T; declare class BaseClass { @@ -57,7 +57,7 @@ declare class BaseClass { } declare const MyClass_base: { new (...args: any[]): { - readonly validationTarget: HTMLElement; + get validationTarget(): HTMLElement; }; } & typeof BaseClass; declare class MyClass extends MyClass_base { diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js.diff index 625e0b6e88..da7fd0def3 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js.diff +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors1.js.diff @@ -7,22 +7,4 @@ -"use strict"; // https://github.com/microsoft/TypeScript/issues/58790 function mixin(superclass) { - return class extends superclass { -@@= skipped -26, +25 lines =@@ - new (...args: any[]): {}; - }>(superclass: T): { - new (...args: any[]): { -- get validationTarget(): HTMLElement; -+ readonly validationTarget: HTMLElement; - }; - } & T; - declare class BaseClass { -@@= skipped -8, +8 lines =@@ - } - declare const MyClass_base: { - new (...args: any[]): { -- get validationTarget(): HTMLElement; -+ readonly validationTarget: HTMLElement; - }; - } & typeof BaseClass; - declare class MyClass extends MyClass_base { \ No newline at end of file + return class extends superclass { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt b/testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt deleted file mode 100644 index 57b9d71d86..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -mixinAccessors2.ts(12,12): error TS2611: 'name' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. - - -==== mixinAccessors2.ts (1 errors) ==== - function mixin(superclass: T) { - return class extends superclass { - accessor name = ""; - }; - } - - class BaseClass { - accessor name = ""; - } - - class MyClass extends mixin(BaseClass) { - accessor name = ""; - ~~~~ -!!! error TS2611: 'name' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt.diff deleted file mode 100644 index 9caf5d592b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.mixinAccessors2.errors.txt -+++ new.mixinAccessors2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mixinAccessors2.ts(12,12): error TS2611: 'name' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. -+ -+ -+==== mixinAccessors2.ts (1 errors) ==== -+ function mixin(superclass: T) { -+ return class extends superclass { -+ accessor name = ""; -+ }; -+ } -+ -+ class BaseClass { -+ accessor name = ""; -+ } -+ -+ class MyClass extends mixin(BaseClass) { -+ accessor name = ""; -+ ~~~~ -+!!! error TS2611: 'name' is defined as a property in class 'mixin.(Anonymous class) & BaseClass', but is overridden here in 'MyClass' as an accessor. -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js b/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js index 9a91ff2634..6d768eb164 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js @@ -35,7 +35,8 @@ declare function mixin(superclass: T): { new (...args: any[]): { - name: string; + get name(): string; + set name(arg: string); }; } & T; declare class BaseClass { @@ -43,7 +44,8 @@ declare class BaseClass { } declare const MyClass_base: { new (...args: any[]): { - name: string; + get name(): string; + set name(arg: string); }; } & typeof BaseClass; declare class MyClass extends MyClass_base { diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js.diff index e344750daf..305c3b5dbb 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js.diff +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors2.js.diff @@ -7,24 +7,4 @@ -"use strict"; function mixin(superclass) { return class extends superclass { - accessor name = ""; -@@= skipped -19, +18 lines =@@ - new (...args: any[]): {}; - }>(superclass: T): { - new (...args: any[]): { -- get name(): string; -- set name(arg: string); -+ name: string; - }; - } & T; - declare class BaseClass { -@@= skipped -9, +8 lines =@@ - } - declare const MyClass_base: { - new (...args: any[]): { -- get name(): string; -- set name(arg: string); -+ name: string; - }; - } & typeof BaseClass; - declare class MyClass extends MyClass_base { \ No newline at end of file + accessor name = ""; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js b/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js index 288505cd09..21ee8151ce 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js @@ -45,7 +45,7 @@ declare function mixin(superclass: T): { new (...args: any[]): { - readonly name: string; + get name(): string; }; } & T; declare class BaseClass { @@ -53,7 +53,7 @@ declare class BaseClass { } declare const MyClass_base: { new (...args: any[]): { - readonly name: string; + get name(): string; }; } & typeof BaseClass; declare class MyClass extends MyClass_base { diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js.diff index 40189dff2d..359905d983 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors3.js.diff @@ -7,22 +7,4 @@ -"use strict"; function mixin(superclass) { return class extends superclass { - get name() { -@@= skipped -24, +23 lines =@@ - new (...args: any[]): {}; - }>(superclass: T): { - new (...args: any[]): { -- get name(): string; -+ readonly name: string; - }; - } & T; - declare class BaseClass { -@@= skipped -8, +8 lines =@@ - } - declare const MyClass_base: { - new (...args: any[]): { -- get name(): string; -+ readonly name: string; - }; - } & typeof BaseClass; - declare class MyClass extends MyClass_base { \ No newline at end of file + get name() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt b/testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt deleted file mode 100644 index 943b39532c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -mixinAccessors4.ts(19,7): error TS2611: 'myName' is defined as a property in class 'Mixin.B & A', but is overridden here in 'C' as an accessor. - - -==== mixinAccessors4.ts (1 errors) ==== - // https://github.com/microsoft/TypeScript/issues/44938 - - class A { - constructor(...args: any[]) {} - get myName(): string { - return "A"; - } - } - - function Mixin(Super: T) { - return class B extends Super { - get myName(): string { - return "B"; - } - }; - } - - class C extends Mixin(A) { - get myName(): string { - ~~~~~~ -!!! error TS2611: 'myName' is defined as a property in class 'Mixin.B & A', but is overridden here in 'C' as an accessor. - return "C"; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt.diff deleted file mode 100644 index 713d5f91aa..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.mixinAccessors4.errors.txt -+++ new.mixinAccessors4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mixinAccessors4.ts(19,7): error TS2611: 'myName' is defined as a property in class 'Mixin.B & A', but is overridden here in 'C' as an accessor. -+ -+ -+==== mixinAccessors4.ts (1 errors) ==== -+ // https://github.com/microsoft/TypeScript/issues/44938 -+ -+ class A { -+ constructor(...args: any[]) {} -+ get myName(): string { -+ return "A"; -+ } -+ } -+ -+ function Mixin(Super: T) { -+ return class B extends Super { -+ get myName(): string { -+ return "B"; -+ } -+ }; -+ } -+ -+ class C extends Mixin(A) { -+ get myName(): string { -+ ~~~~~~ -+!!! error TS2611: 'myName' is defined as a property in class 'Mixin.B & A', but is overridden here in 'C' as an accessor. -+ return "C"; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js b/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js index b5851f7dfc..9c8660bd82 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js @@ -54,12 +54,12 @@ declare class A { } declare function Mixin(Super: T): { new (...args: any[]): { - readonly myName: string; + get myName(): string; }; } & T; declare const C_base: { new (...args: any[]): { - readonly myName: string; + get myName(): string; }; } & typeof A; declare class C extends C_base { diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js.diff index 686537db8b..90ad28b02f 100644 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js.diff +++ b/testdata/baselines/reference/submodule/conformance/mixinAccessors4.js.diff @@ -7,19 +7,4 @@ -"use strict"; // https://github.com/microsoft/TypeScript/issues/44938 class A { - constructor(...args) { } -@@= skipped -29, +28 lines =@@ - } - declare function Mixin(Super: T): { - new (...args: any[]): { -- get myName(): string; -+ readonly myName: string; - }; - } & T; - declare const C_base: { - new (...args: any[]): { -- get myName(): string; -+ readonly myName: string; - }; - } & typeof A; - declare class C extends C_base { \ No newline at end of file + constructor(...args) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt b/testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt deleted file mode 100644 index 0a40860b18..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -mixinAccessors5.ts(21,16): error TS2611: 'inCompendium' is defined as a property in class 'GetterA & GetterB', but is overridden here in 'TestB' as an accessor. - - -==== mixinAccessors5.ts (1 errors) ==== - // https://github.com/microsoft/TypeScript/issues/61967 - - declare function basicMixin( - t: T, - u: U, - ): T & U; - - declare class GetterA { - constructor(...args: any[]); - - get inCompendium(): boolean; - } - - declare class GetterB { - constructor(...args: any[]); - - get inCompendium(): boolean; - } - - declare class TestB extends basicMixin(GetterA, GetterB) { - override get inCompendium(): boolean; - ~~~~~~~~~~~~ -!!! error TS2611: 'inCompendium' is defined as a property in class 'GetterA & GetterB', but is overridden here in 'TestB' as an accessor. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt.diff deleted file mode 100644 index b50fb4e676..0000000000 --- a/testdata/baselines/reference/submodule/conformance/mixinAccessors5.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.mixinAccessors5.errors.txt -+++ new.mixinAccessors5.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mixinAccessors5.ts(21,16): error TS2611: 'inCompendium' is defined as a property in class 'GetterA & GetterB', but is overridden here in 'TestB' as an accessor. -+ -+ -+==== mixinAccessors5.ts (1 errors) ==== -+ // https://github.com/microsoft/TypeScript/issues/61967 -+ -+ declare function basicMixin( -+ t: T, -+ u: U, -+ ): T & U; -+ -+ declare class GetterA { -+ constructor(...args: any[]); -+ -+ get inCompendium(): boolean; -+ } -+ -+ declare class GetterB { -+ constructor(...args: any[]); -+ -+ get inCompendium(): boolean; -+ } -+ -+ declare class TestB extends basicMixin(GetterA, GetterB) { -+ override get inCompendium(): boolean; -+ ~~~~~~~~~~~~ -+!!! error TS2611: 'inCompendium' is defined as a property in class 'GetterA & GetterB', but is overridden here in 'TestB' as an accessor. -+ } -+ \ No newline at end of file