Add regression test
This commit is contained in:
parent
4aeab77783
commit
0b8a9fc3d0
4 changed files with 182 additions and 0 deletions
56
tests/baselines/reference/indexedAccessRelation.js
Normal file
56
tests/baselines/reference/indexedAccessRelation.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
//// [indexedAccessRelation.ts]
|
||||||
|
// Repro from #14723
|
||||||
|
|
||||||
|
class Component<S> {
|
||||||
|
setState<K extends keyof S>(state: Pick<S, K>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface State<T> {
|
||||||
|
a?: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo {}
|
||||||
|
|
||||||
|
class Comp<T extends Foo, S> extends Component<S & State<T>>
|
||||||
|
{
|
||||||
|
foo(a: T) {
|
||||||
|
this.setState({ a: a });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//// [indexedAccessRelation.js]
|
||||||
|
// Repro from #14723
|
||||||
|
"use strict";
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||||
|
return function (d, b) {
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
exports.__esModule = true;
|
||||||
|
var Component = (function () {
|
||||||
|
function Component() {
|
||||||
|
}
|
||||||
|
Component.prototype.setState = function (state) { };
|
||||||
|
return Component;
|
||||||
|
}());
|
||||||
|
var Foo = (function () {
|
||||||
|
function Foo() {
|
||||||
|
}
|
||||||
|
return Foo;
|
||||||
|
}());
|
||||||
|
var Comp = (function (_super) {
|
||||||
|
__extends(Comp, _super);
|
||||||
|
function Comp() {
|
||||||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
|
}
|
||||||
|
Comp.prototype.foo = function (a) {
|
||||||
|
this.setState({ a: a });
|
||||||
|
};
|
||||||
|
return Comp;
|
||||||
|
}(Component));
|
53
tests/baselines/reference/indexedAccessRelation.symbols
Normal file
53
tests/baselines/reference/indexedAccessRelation.symbols
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
=== tests/cases/compiler/indexedAccessRelation.ts ===
|
||||||
|
// Repro from #14723
|
||||||
|
|
||||||
|
class Component<S> {
|
||||||
|
>Component : Symbol(Component, Decl(indexedAccessRelation.ts, 0, 0))
|
||||||
|
>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16))
|
||||||
|
|
||||||
|
setState<K extends keyof S>(state: Pick<S, K>) {}
|
||||||
|
>setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20))
|
||||||
|
>K : Symbol(K, Decl(indexedAccessRelation.ts, 3, 13))
|
||||||
|
>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16))
|
||||||
|
>state : Symbol(state, Decl(indexedAccessRelation.ts, 3, 32))
|
||||||
|
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||||
|
>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16))
|
||||||
|
>K : Symbol(K, Decl(indexedAccessRelation.ts, 3, 13))
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface State<T> {
|
||||||
|
>State : Symbol(State, Decl(indexedAccessRelation.ts, 4, 1))
|
||||||
|
>T : Symbol(T, Decl(indexedAccessRelation.ts, 6, 23))
|
||||||
|
|
||||||
|
a?: T;
|
||||||
|
>a : Symbol(State.a, Decl(indexedAccessRelation.ts, 6, 27))
|
||||||
|
>T : Symbol(T, Decl(indexedAccessRelation.ts, 6, 23))
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo {}
|
||||||
|
>Foo : Symbol(Foo, Decl(indexedAccessRelation.ts, 8, 1))
|
||||||
|
|
||||||
|
class Comp<T extends Foo, S> extends Component<S & State<T>>
|
||||||
|
>Comp : Symbol(Comp, Decl(indexedAccessRelation.ts, 10, 12))
|
||||||
|
>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11))
|
||||||
|
>Foo : Symbol(Foo, Decl(indexedAccessRelation.ts, 8, 1))
|
||||||
|
>S : Symbol(S, Decl(indexedAccessRelation.ts, 12, 25))
|
||||||
|
>Component : Symbol(Component, Decl(indexedAccessRelation.ts, 0, 0))
|
||||||
|
>S : Symbol(S, Decl(indexedAccessRelation.ts, 12, 25))
|
||||||
|
>State : Symbol(State, Decl(indexedAccessRelation.ts, 4, 1))
|
||||||
|
>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11))
|
||||||
|
{
|
||||||
|
foo(a: T) {
|
||||||
|
>foo : Symbol(Comp.foo, Decl(indexedAccessRelation.ts, 13, 1))
|
||||||
|
>a : Symbol(a, Decl(indexedAccessRelation.ts, 14, 8))
|
||||||
|
>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11))
|
||||||
|
|
||||||
|
this.setState({ a: a });
|
||||||
|
>this.setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20))
|
||||||
|
>this : Symbol(Comp, Decl(indexedAccessRelation.ts, 10, 12))
|
||||||
|
>setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20))
|
||||||
|
>a : Symbol(a, Decl(indexedAccessRelation.ts, 15, 23))
|
||||||
|
>a : Symbol(a, Decl(indexedAccessRelation.ts, 14, 8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
55
tests/baselines/reference/indexedAccessRelation.types
Normal file
55
tests/baselines/reference/indexedAccessRelation.types
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
=== tests/cases/compiler/indexedAccessRelation.ts ===
|
||||||
|
// Repro from #14723
|
||||||
|
|
||||||
|
class Component<S> {
|
||||||
|
>Component : Component<S>
|
||||||
|
>S : S
|
||||||
|
|
||||||
|
setState<K extends keyof S>(state: Pick<S, K>) {}
|
||||||
|
>setState : <K extends keyof S>(state: Pick<S, K>) => void
|
||||||
|
>K : K
|
||||||
|
>S : S
|
||||||
|
>state : Pick<S, K>
|
||||||
|
>Pick : Pick<T, K>
|
||||||
|
>S : S
|
||||||
|
>K : K
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface State<T> {
|
||||||
|
>State : State<T>
|
||||||
|
>T : T
|
||||||
|
|
||||||
|
a?: T;
|
||||||
|
>a : T
|
||||||
|
>T : T
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo {}
|
||||||
|
>Foo : Foo
|
||||||
|
|
||||||
|
class Comp<T extends Foo, S> extends Component<S & State<T>>
|
||||||
|
>Comp : Comp<T, S>
|
||||||
|
>T : T
|
||||||
|
>Foo : Foo
|
||||||
|
>S : S
|
||||||
|
>Component : Component<S & State<T>>
|
||||||
|
>S : S
|
||||||
|
>State : State<T>
|
||||||
|
>T : T
|
||||||
|
{
|
||||||
|
foo(a: T) {
|
||||||
|
>foo : (a: T) => void
|
||||||
|
>a : T
|
||||||
|
>T : T
|
||||||
|
|
||||||
|
this.setState({ a: a });
|
||||||
|
>this.setState({ a: a }) : void
|
||||||
|
>this.setState : <K extends keyof (S & State<T>)>(state: Pick<S & State<T>, K>) => void
|
||||||
|
>this : this
|
||||||
|
>setState : <K extends keyof (S & State<T>)>(state: Pick<S & State<T>, K>) => void
|
||||||
|
>{ a: a } : { a: T; }
|
||||||
|
>a : T
|
||||||
|
>a : T
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
tests/cases/compiler/indexedAccessRelation.ts
Normal file
18
tests/cases/compiler/indexedAccessRelation.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Repro from #14723
|
||||||
|
|
||||||
|
class Component<S> {
|
||||||
|
setState<K extends keyof S>(state: Pick<S, K>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface State<T> {
|
||||||
|
a?: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo {}
|
||||||
|
|
||||||
|
class Comp<T extends Foo, S> extends Component<S & State<T>>
|
||||||
|
{
|
||||||
|
foo(a: T) {
|
||||||
|
this.setState({ a: a });
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue