-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix declaration/quick info for abstract construct signatures
- Loading branch information
Showing
9 changed files
with
232 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
63 changes: 63 additions & 0 deletions
63
tests/baselines/reference/mixinAbstractClassesReturnTypeInference.js
This file contains 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,63 @@ | ||
//// [mixinAbstractClassesReturnTypeInference.ts] | ||
interface Mixin1 { | ||
mixinMethod(): void; | ||
} | ||
|
||
abstract class AbstractBase { | ||
abstract abstractBaseMethod(): void; | ||
} | ||
|
||
function Mixin2<TBase extends abstract new (...args: any[]) => any>(baseClass: TBase) { | ||
// must be `abstract` because we cannot know *all* of the possible abstract members that need to be | ||
// implemented for this to be concrete. | ||
abstract class MixinClass extends baseClass implements Mixin1 { | ||
mixinMethod(): void {} | ||
static staticMixinMethod(): void {} | ||
} | ||
return MixinClass; | ||
} | ||
|
||
class DerivedFromAbstract2 extends Mixin2(AbstractBase) { | ||
abstractBaseMethod() {} | ||
} | ||
|
||
|
||
//// [mixinAbstractClassesReturnTypeInference.js] | ||
class AbstractBase { | ||
} | ||
function Mixin2(baseClass) { | ||
// must be `abstract` because we cannot know *all* of the possible abstract members that need to be | ||
// implemented for this to be concrete. | ||
class MixinClass extends baseClass { | ||
mixinMethod() { } | ||
static staticMixinMethod() { } | ||
} | ||
return MixinClass; | ||
} | ||
class DerivedFromAbstract2 extends Mixin2(AbstractBase) { | ||
abstractBaseMethod() { } | ||
} | ||
|
||
|
||
//// [mixinAbstractClassesReturnTypeInference.d.ts] | ||
interface Mixin1 { | ||
mixinMethod(): void; | ||
} | ||
declare abstract class AbstractBase { | ||
abstract abstractBaseMethod(): void; | ||
} | ||
declare function Mixin2<TBase extends abstract new (...args: any[]) => any>(baseClass: TBase): ((abstract new (...args: any[]) => { | ||
[x: string]: any; | ||
mixinMethod(): void; | ||
}) & { | ||
staticMixinMethod(): void; | ||
}) & TBase; | ||
declare const DerivedFromAbstract2_base: ((abstract new (...args: any[]) => { | ||
[x: string]: any; | ||
mixinMethod(): void; | ||
}) & { | ||
staticMixinMethod(): void; | ||
}) & typeof AbstractBase; | ||
declare class DerivedFromAbstract2 extends DerivedFromAbstract2_base { | ||
abstractBaseMethod(): void; | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/mixinAbstractClassesReturnTypeInference.symbols
This file contains 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,48 @@ | ||
=== tests/cases/conformance/classes/mixinAbstractClassesReturnTypeInference.ts === | ||
interface Mixin1 { | ||
>Mixin1 : Symbol(Mixin1, Decl(mixinAbstractClassesReturnTypeInference.ts, 0, 0)) | ||
|
||
mixinMethod(): void; | ||
>mixinMethod : Symbol(Mixin1.mixinMethod, Decl(mixinAbstractClassesReturnTypeInference.ts, 0, 18)) | ||
} | ||
|
||
abstract class AbstractBase { | ||
>AbstractBase : Symbol(AbstractBase, Decl(mixinAbstractClassesReturnTypeInference.ts, 2, 1)) | ||
|
||
abstract abstractBaseMethod(): void; | ||
>abstractBaseMethod : Symbol(AbstractBase.abstractBaseMethod, Decl(mixinAbstractClassesReturnTypeInference.ts, 4, 29)) | ||
} | ||
|
||
function Mixin2<TBase extends abstract new (...args: any[]) => any>(baseClass: TBase) { | ||
>Mixin2 : Symbol(Mixin2, Decl(mixinAbstractClassesReturnTypeInference.ts, 6, 1)) | ||
>TBase : Symbol(TBase, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 16)) | ||
>args : Symbol(args, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 44)) | ||
>baseClass : Symbol(baseClass, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 68)) | ||
>TBase : Symbol(TBase, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 16)) | ||
|
||
// must be `abstract` because we cannot know *all* of the possible abstract members that need to be | ||
// implemented for this to be concrete. | ||
abstract class MixinClass extends baseClass implements Mixin1 { | ||
>MixinClass : Symbol(MixinClass, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 87)) | ||
>baseClass : Symbol(baseClass, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 68)) | ||
>Mixin1 : Symbol(Mixin1, Decl(mixinAbstractClassesReturnTypeInference.ts, 0, 0)) | ||
|
||
mixinMethod(): void {} | ||
>mixinMethod : Symbol(MixinClass.mixinMethod, Decl(mixinAbstractClassesReturnTypeInference.ts, 11, 67)) | ||
|
||
static staticMixinMethod(): void {} | ||
>staticMixinMethod : Symbol(MixinClass.staticMixinMethod, Decl(mixinAbstractClassesReturnTypeInference.ts, 12, 30)) | ||
} | ||
return MixinClass; | ||
>MixinClass : Symbol(MixinClass, Decl(mixinAbstractClassesReturnTypeInference.ts, 8, 87)) | ||
} | ||
|
||
class DerivedFromAbstract2 extends Mixin2(AbstractBase) { | ||
>DerivedFromAbstract2 : Symbol(DerivedFromAbstract2, Decl(mixinAbstractClassesReturnTypeInference.ts, 16, 1)) | ||
>Mixin2 : Symbol(Mixin2, Decl(mixinAbstractClassesReturnTypeInference.ts, 6, 1)) | ||
>AbstractBase : Symbol(AbstractBase, Decl(mixinAbstractClassesReturnTypeInference.ts, 2, 1)) | ||
|
||
abstractBaseMethod() {} | ||
>abstractBaseMethod : Symbol(DerivedFromAbstract2.abstractBaseMethod, Decl(mixinAbstractClassesReturnTypeInference.ts, 18, 57)) | ||
} | ||
|
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/mixinAbstractClassesReturnTypeInference.types
This file contains 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,44 @@ | ||
=== tests/cases/conformance/classes/mixinAbstractClassesReturnTypeInference.ts === | ||
interface Mixin1 { | ||
mixinMethod(): void; | ||
>mixinMethod : () => void | ||
} | ||
|
||
abstract class AbstractBase { | ||
>AbstractBase : AbstractBase | ||
|
||
abstract abstractBaseMethod(): void; | ||
>abstractBaseMethod : () => void | ||
} | ||
|
||
function Mixin2<TBase extends abstract new (...args: any[]) => any>(baseClass: TBase) { | ||
>Mixin2 : <TBase extends abstract new (...args: any[]) => any>(baseClass: TBase) => ((abstract new (...args: any[]) => MixinClass) & { prototype: Mixin2<any>.MixinClass; staticMixinMethod(): void; }) & TBase | ||
>args : any[] | ||
>baseClass : TBase | ||
|
||
// must be `abstract` because we cannot know *all* of the possible abstract members that need to be | ||
// implemented for this to be concrete. | ||
abstract class MixinClass extends baseClass implements Mixin1 { | ||
>MixinClass : MixinClass | ||
>baseClass : TBase | ||
|
||
mixinMethod(): void {} | ||
>mixinMethod : () => void | ||
|
||
static staticMixinMethod(): void {} | ||
>staticMixinMethod : () => void | ||
} | ||
return MixinClass; | ||
>MixinClass : ((abstract new (...args: any[]) => MixinClass) & { prototype: Mixin2<any>.MixinClass; staticMixinMethod(): void; }) & TBase | ||
} | ||
|
||
class DerivedFromAbstract2 extends Mixin2(AbstractBase) { | ||
>DerivedFromAbstract2 : DerivedFromAbstract2 | ||
>Mixin2(AbstractBase) : Mixin2<typeof AbstractBase>.MixinClass & AbstractBase | ||
>Mixin2 : <TBase extends abstract new (...args: any[]) => any>(baseClass: TBase) => ((abstract new (...args: any[]) => MixinClass) & { prototype: Mixin2<any>.MixinClass; staticMixinMethod(): void; }) & TBase | ||
>AbstractBase : typeof AbstractBase | ||
|
||
abstractBaseMethod() {} | ||
>abstractBaseMethod : () => void | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/cases/conformance/classes/mixinAbstractClassesReturnTypeInference.ts
This file contains 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,24 @@ | ||
// @target: esnext | ||
// @declaration: true | ||
|
||
interface Mixin1 { | ||
mixinMethod(): void; | ||
} | ||
|
||
abstract class AbstractBase { | ||
abstract abstractBaseMethod(): void; | ||
} | ||
|
||
function Mixin2<TBase extends abstract new (...args: any[]) => any>(baseClass: TBase) { | ||
// must be `abstract` because we cannot know *all* of the possible abstract members that need to be | ||
// implemented for this to be concrete. | ||
abstract class MixinClass extends baseClass implements Mixin1 { | ||
mixinMethod(): void {} | ||
static staticMixinMethod(): void {} | ||
} | ||
return MixinClass; | ||
} | ||
|
||
class DerivedFromAbstract2 extends Mixin2(AbstractBase) { | ||
abstractBaseMethod() {} | ||
} |