-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure all default type params are mapped to some default even in cir…
…cular scenarios (#28423) * Ensure all default type params are mapped to some default even in circular scenarios * Add js example, fix typo
- Loading branch information
Showing
5 changed files
with
232 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//// [tests/cases/compiler/subclassThisTypeAssignable.ts] //// | ||
|
||
//// [tile1.ts] | ||
interface Lifecycle<Attrs, State> { | ||
oninit?(vnode: Vnode<Attrs, State>): number; | ||
[_: number]: any; | ||
} | ||
|
||
interface Vnode<Attrs, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> { | ||
tag: Component<Attrs, State>; | ||
} | ||
|
||
interface Component<Attrs, State> { | ||
view(this: State, vnode: Vnode<Attrs, State>): number; | ||
} | ||
|
||
interface ClassComponent<A> extends Lifecycle<A, ClassComponent<A>> { | ||
oninit?(vnode: Vnode<A, this>): number; | ||
view(vnode: Vnode<A, this>): number; | ||
} | ||
|
||
interface MyAttrs { id: number } | ||
class C implements ClassComponent<MyAttrs> { | ||
view(v: Vnode<MyAttrs>) { return 0; } | ||
} | ||
|
||
const test8: ClassComponent<any> = new C(); | ||
//// [file1.js] | ||
/** @type {ClassComponent<any>} */ | ||
const test9 = new C(); | ||
|
||
|
||
//// [tile1.js] | ||
var C = /** @class */ (function () { | ||
function C() { | ||
} | ||
C.prototype.view = function (v) { return 0; }; | ||
return C; | ||
}()); | ||
var test8 = new C(); | ||
//// [file1.js] | ||
/** @type {ClassComponent<any>} */ | ||
var test9 = new C(); |
98 changes: 98 additions & 0 deletions
98
tests/baselines/reference/subclassThisTypeAssignable.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,98 @@ | ||
=== tests/cases/compiler/tile1.ts === | ||
interface Lifecycle<Attrs, State> { | ||
>Lifecycle : Symbol(Lifecycle, Decl(tile1.ts, 0, 0)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 0, 20)) | ||
>State : Symbol(State, Decl(tile1.ts, 0, 26)) | ||
|
||
oninit?(vnode: Vnode<Attrs, State>): number; | ||
>oninit : Symbol(Lifecycle.oninit, Decl(tile1.ts, 0, 35)) | ||
>vnode : Symbol(vnode, Decl(tile1.ts, 1, 9)) | ||
>Vnode : Symbol(Vnode, Decl(tile1.ts, 3, 1)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 0, 20)) | ||
>State : Symbol(State, Decl(tile1.ts, 0, 26)) | ||
|
||
[_: number]: any; | ||
>_ : Symbol(_, Decl(tile1.ts, 2, 2)) | ||
} | ||
|
||
interface Vnode<Attrs, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> { | ||
>Vnode : Symbol(Vnode, Decl(tile1.ts, 3, 1)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 5, 16)) | ||
>State : Symbol(State, Decl(tile1.ts, 5, 22)) | ||
>Lifecycle : Symbol(Lifecycle, Decl(tile1.ts, 0, 0)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 5, 16)) | ||
>State : Symbol(State, Decl(tile1.ts, 5, 22)) | ||
>Lifecycle : Symbol(Lifecycle, Decl(tile1.ts, 0, 0)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 5, 16)) | ||
>State : Symbol(State, Decl(tile1.ts, 5, 22)) | ||
|
||
tag: Component<Attrs, State>; | ||
>tag : Symbol(Vnode.tag, Decl(tile1.ts, 5, 89)) | ||
>Component : Symbol(Component, Decl(tile1.ts, 7, 1)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 5, 16)) | ||
>State : Symbol(State, Decl(tile1.ts, 5, 22)) | ||
} | ||
|
||
interface Component<Attrs, State> { | ||
>Component : Symbol(Component, Decl(tile1.ts, 7, 1)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 9, 20)) | ||
>State : Symbol(State, Decl(tile1.ts, 9, 26)) | ||
|
||
view(this: State, vnode: Vnode<Attrs, State>): number; | ||
>view : Symbol(Component.view, Decl(tile1.ts, 9, 35)) | ||
>this : Symbol(this, Decl(tile1.ts, 10, 6)) | ||
>State : Symbol(State, Decl(tile1.ts, 9, 26)) | ||
>vnode : Symbol(vnode, Decl(tile1.ts, 10, 18)) | ||
>Vnode : Symbol(Vnode, Decl(tile1.ts, 3, 1)) | ||
>Attrs : Symbol(Attrs, Decl(tile1.ts, 9, 20)) | ||
>State : Symbol(State, Decl(tile1.ts, 9, 26)) | ||
} | ||
|
||
interface ClassComponent<A> extends Lifecycle<A, ClassComponent<A>> { | ||
>ClassComponent : Symbol(ClassComponent, Decl(tile1.ts, 11, 1)) | ||
>A : Symbol(A, Decl(tile1.ts, 13, 25)) | ||
>Lifecycle : Symbol(Lifecycle, Decl(tile1.ts, 0, 0)) | ||
>A : Symbol(A, Decl(tile1.ts, 13, 25)) | ||
>ClassComponent : Symbol(ClassComponent, Decl(tile1.ts, 11, 1)) | ||
>A : Symbol(A, Decl(tile1.ts, 13, 25)) | ||
|
||
oninit?(vnode: Vnode<A, this>): number; | ||
>oninit : Symbol(ClassComponent.oninit, Decl(tile1.ts, 13, 69)) | ||
>vnode : Symbol(vnode, Decl(tile1.ts, 14, 9)) | ||
>Vnode : Symbol(Vnode, Decl(tile1.ts, 3, 1)) | ||
>A : Symbol(A, Decl(tile1.ts, 13, 25)) | ||
|
||
view(vnode: Vnode<A, this>): number; | ||
>view : Symbol(ClassComponent.view, Decl(tile1.ts, 14, 40)) | ||
>vnode : Symbol(vnode, Decl(tile1.ts, 15, 6)) | ||
>Vnode : Symbol(Vnode, Decl(tile1.ts, 3, 1)) | ||
>A : Symbol(A, Decl(tile1.ts, 13, 25)) | ||
} | ||
|
||
interface MyAttrs { id: number } | ||
>MyAttrs : Symbol(MyAttrs, Decl(tile1.ts, 16, 1)) | ||
>id : Symbol(MyAttrs.id, Decl(tile1.ts, 18, 19)) | ||
|
||
class C implements ClassComponent<MyAttrs> { | ||
>C : Symbol(C, Decl(tile1.ts, 18, 32)) | ||
>ClassComponent : Symbol(ClassComponent, Decl(tile1.ts, 11, 1)) | ||
>MyAttrs : Symbol(MyAttrs, Decl(tile1.ts, 16, 1)) | ||
|
||
view(v: Vnode<MyAttrs>) { return 0; } | ||
>view : Symbol(C.view, Decl(tile1.ts, 19, 44)) | ||
>v : Symbol(v, Decl(tile1.ts, 20, 6)) | ||
>Vnode : Symbol(Vnode, Decl(tile1.ts, 3, 1)) | ||
>MyAttrs : Symbol(MyAttrs, Decl(tile1.ts, 16, 1)) | ||
} | ||
|
||
const test8: ClassComponent<any> = new C(); | ||
>test8 : Symbol(test8, Decl(tile1.ts, 23, 5)) | ||
>ClassComponent : Symbol(ClassComponent, Decl(tile1.ts, 11, 1)) | ||
>C : Symbol(C, Decl(tile1.ts, 18, 32)) | ||
|
||
=== tests/cases/compiler/file1.js === | ||
/** @type {ClassComponent<any>} */ | ||
const test9 = new C(); | ||
>test9 : Symbol(test9, Decl(file1.js, 1, 5)) | ||
>C : Symbol(C, Decl(tile1.ts, 18, 32)) | ||
|
56 changes: 56 additions & 0 deletions
56
tests/baselines/reference/subclassThisTypeAssignable.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,56 @@ | ||
=== tests/cases/compiler/tile1.ts === | ||
interface Lifecycle<Attrs, State> { | ||
oninit?(vnode: Vnode<Attrs, State>): number; | ||
>oninit : (vnode: Vnode<Attrs, State>) => number | ||
>vnode : Vnode<Attrs, State> | ||
|
||
[_: number]: any; | ||
>_ : number | ||
} | ||
|
||
interface Vnode<Attrs, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> { | ||
tag: Component<Attrs, State>; | ||
>tag : Component<Attrs, State> | ||
} | ||
|
||
interface Component<Attrs, State> { | ||
view(this: State, vnode: Vnode<Attrs, State>): number; | ||
>view : (this: State, vnode: Vnode<Attrs, State>) => number | ||
>this : State | ||
>vnode : Vnode<Attrs, State> | ||
} | ||
|
||
interface ClassComponent<A> extends Lifecycle<A, ClassComponent<A>> { | ||
oninit?(vnode: Vnode<A, this>): number; | ||
>oninit : (vnode: Vnode<A, this>) => number | ||
>vnode : Vnode<A, this> | ||
|
||
view(vnode: Vnode<A, this>): number; | ||
>view : (vnode: Vnode<A, this>) => number | ||
>vnode : Vnode<A, this> | ||
} | ||
|
||
interface MyAttrs { id: number } | ||
>id : number | ||
|
||
class C implements ClassComponent<MyAttrs> { | ||
>C : C | ||
|
||
view(v: Vnode<MyAttrs>) { return 0; } | ||
>view : (v: Vnode<MyAttrs, Lifecycle<MyAttrs, Lifecycle<{}, {}>>>) => number | ||
>v : Vnode<MyAttrs, Lifecycle<MyAttrs, Lifecycle<{}, {}>>> | ||
>0 : 0 | ||
} | ||
|
||
const test8: ClassComponent<any> = new C(); | ||
>test8 : ClassComponent<any> | ||
>new C() : C | ||
>C : typeof C | ||
|
||
=== tests/cases/compiler/file1.js === | ||
/** @type {ClassComponent<any>} */ | ||
const test9 = new C(); | ||
>test9 : ClassComponent<any> | ||
>new C() : C | ||
>C : typeof C | ||
|
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,31 @@ | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @outDir: ./out | ||
// @filename: tile1.ts | ||
interface Lifecycle<Attrs, State> { | ||
oninit?(vnode: Vnode<Attrs, State>): number; | ||
[_: number]: any; | ||
} | ||
|
||
interface Vnode<Attrs, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> { | ||
tag: Component<Attrs, State>; | ||
} | ||
|
||
interface Component<Attrs, State> { | ||
view(this: State, vnode: Vnode<Attrs, State>): number; | ||
} | ||
|
||
interface ClassComponent<A> extends Lifecycle<A, ClassComponent<A>> { | ||
oninit?(vnode: Vnode<A, this>): number; | ||
view(vnode: Vnode<A, this>): number; | ||
} | ||
|
||
interface MyAttrs { id: number } | ||
class C implements ClassComponent<MyAttrs> { | ||
view(v: Vnode<MyAttrs>) { return 0; } | ||
} | ||
|
||
const test8: ClassComponent<any> = new C(); | ||
// @filename: file1.js | ||
/** @type {ClassComponent<any>} */ | ||
const test9 = new C(); |