Fix non-thenable check for IndexedAccess types

This commit is contained in:
Ron Buckton
2016-12-22 14:05:03 -08:00
parent 7e98fc71d0
commit decc7c220e
5 changed files with 773 additions and 7 deletions

View File

@@ -3074,10 +3074,6 @@ namespace ts {
return type && (type.flags & TypeFlags.Any) !== 0;
}
function isTypeNever(type: Type) {
return type && (type.flags & TypeFlags.Never) !== 0;
}
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
// assigned by contextual typing.
function getTypeForBindingElementParent(node: VariableLikeDeclaration) {
@@ -16285,9 +16281,18 @@ namespace ts {
}
}
function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) {
function isTypeOrConstraintAnyOrNever(type: Type) {
while (type.flags & TypeFlags.TypeVariable) {
const constraint = getConstraintOfTypeVariable(<TypeVariable>type);
if (!constraint) break;
type = getWidenedType(constraint);
}
return (type.flags & (TypeFlags.Any | TypeFlags.Never)) !== 0;
}
function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage): Type {
type = getWidenedType(type);
if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
if (!isTypeOrConstraintAnyOrNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
if (location) {
if (!message) {
message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member;

View File

@@ -8,7 +8,72 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
// This is contextually typed as a tuple.
return [1, true];
}
// https://github.com/Microsoft/TypeScript/issues/13128
interface Obj {
stringProp: string;
anyProp: any;
}
async function fIndexedTypeForStringProp(obj: Obj): Promise<Obj["stringProp"]> {
return obj.stringProp;
}
async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
return Promise.resolve(obj.stringProp);
}
async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
}
async function fIndexedTypeForAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
return obj.anyProp;
}
async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
return Promise.resolve(obj.anyProp);
}
async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
}
async function fGenericIndexedTypeForStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
return obj.stringProp;
}
async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
return Promise.resolve(obj.stringProp);
}
async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
}
async function fGenericIndexedTypeForAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
return obj.anyProp;
}
async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
return Promise.resolve(obj.anyProp);
}
async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
}
async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return obj[key];
}
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return Promise.resolve(obj[key]);
}
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return Promise.resolve<TObj[K]>(obj[key]);
}
//// [asyncFunctionReturnType.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -31,3 +96,78 @@ function fAsyncExplicit() {
return [1, true];
});
}
function fIndexedTypeForStringProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return obj.stringProp;
});
}
function fIndexedTypeForPromiseOfStringProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.stringProp);
});
}
function fIndexedTypeForExplicitPromiseOfStringProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.stringProp);
});
}
function fIndexedTypeForAnyProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return obj.anyProp;
});
}
function fIndexedTypeForPromiseOfAnyProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.anyProp);
});
}
function fIndexedTypeForExplicitPromiseOfAnyProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.anyProp);
});
}
function fGenericIndexedTypeForStringProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return obj.stringProp;
});
}
function fGenericIndexedTypeForPromiseOfStringProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.stringProp);
});
}
function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.stringProp);
});
}
function fGenericIndexedTypeForAnyProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return obj.anyProp;
});
}
function fGenericIndexedTypeForPromiseOfAnyProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.anyProp);
});
}
function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj.anyProp);
});
}
function fGenericIndexedTypeForKProp(obj, key) {
return __awaiter(this, void 0, void 0, function* () {
return obj[key];
});
}
function fGenericIndexedTypeForPromiseOfKProp(obj, key) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj[key]);
});
}
function fGenericIndexedTypeForExplicitPromiseOfKProp(obj, key) {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(obj[key]);
});
}

View File

@@ -14,3 +14,274 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
return [1, true];
}
// https://github.com/Microsoft/TypeScript/issues/13128
interface Obj {
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
stringProp: string;
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
anyProp: any;
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fIndexedTypeForStringProp(obj: Obj): Promise<Obj["stringProp"]> {
>fIndexedTypeForStringProp : Symbol(fIndexedTypeForStringProp, Decl(asyncFunctionReturnType.ts, 14, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 16, 41))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
return obj.stringProp;
>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 16, 41))
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
}
async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
>fIndexedTypeForPromiseOfStringProp : Symbol(fIndexedTypeForPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 18, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 20, 50))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
return Promise.resolve(obj.stringProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 20, 50))
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
}
async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
>fIndexedTypeForExplicitPromiseOfStringProp : Symbol(fIndexedTypeForExplicitPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 22, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 24, 58))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 24, 58))
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
}
async function fIndexedTypeForAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
>fIndexedTypeForAnyProp : Symbol(fIndexedTypeForAnyProp, Decl(asyncFunctionReturnType.ts, 26, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 28, 38))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
return obj.anyProp;
>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 28, 38))
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
>fIndexedTypeForPromiseOfAnyProp : Symbol(fIndexedTypeForPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 30, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 32, 47))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
return Promise.resolve(obj.anyProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 32, 47))
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
>fIndexedTypeForExplicitPromiseOfAnyProp : Symbol(fIndexedTypeForExplicitPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 34, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 36, 55))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 36, 55))
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fGenericIndexedTypeForStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
>fGenericIndexedTypeForStringProp : Symbol(fGenericIndexedTypeForStringProp, Decl(asyncFunctionReturnType.ts, 38, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 40, 66))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48))
return obj.stringProp;
>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 40, 66))
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
}
async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
>fGenericIndexedTypeForPromiseOfStringProp : Symbol(fGenericIndexedTypeForPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 42, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 44, 75))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57))
return Promise.resolve(obj.stringProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 44, 75))
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
}
async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
>fGenericIndexedTypeForExplicitPromiseOfStringProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 46, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 48, 83))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65))
return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65))
>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 48, 83))
>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15))
}
async function fGenericIndexedTypeForAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
>fGenericIndexedTypeForAnyProp : Symbol(fGenericIndexedTypeForAnyProp, Decl(asyncFunctionReturnType.ts, 50, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 52, 63))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45))
return obj.anyProp;
>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 52, 63))
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
>fGenericIndexedTypeForPromiseOfAnyProp : Symbol(fGenericIndexedTypeForPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 54, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 56, 72))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54))
return Promise.resolve(obj.anyProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 56, 72))
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
>fGenericIndexedTypeForExplicitPromiseOfAnyProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 58, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 60, 80))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62))
return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62))
>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 60, 80))
>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23))
}
async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForKProp : Symbol(fGenericIndexedTypeForKProp, Decl(asyncFunctionReturnType.ts, 62, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 64, 83))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60))
return obj[key];
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 64, 83))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93))
}
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForPromiseOfKProp : Symbol(fGenericIndexedTypeForPromiseOfKProp, Decl(asyncFunctionReturnType.ts, 66, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 68, 92))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69))
return Promise.resolve(obj[key]);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 68, 92))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102))
}
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForExplicitPromiseOfKProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfKProp, Decl(asyncFunctionReturnType.ts, 70, 1))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60))
>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 72, 100))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77))
return Promise.resolve<TObj[K]>(obj[key]);
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60))
>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77))
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 72, 100))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110))
}

View File

@@ -20,3 +20,287 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
>true : true
}
// https://github.com/Microsoft/TypeScript/issues/13128
interface Obj {
>Obj : Obj
stringProp: string;
>stringProp : string
anyProp: any;
>anyProp : any
}
async function fIndexedTypeForStringProp(obj: Obj): Promise<Obj["stringProp"]> {
>fIndexedTypeForStringProp : (obj: Obj) => Promise<string>
>obj : Obj
>Obj : Obj
>Promise : Promise<T>
>Obj : Obj
return obj.stringProp;
>obj.stringProp : string
>obj : Obj
>stringProp : string
}
async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
>fIndexedTypeForPromiseOfStringProp : (obj: Obj) => Promise<string>
>obj : Obj
>Obj : Obj
>Promise : Promise<T>
>Obj : Obj
return Promise.resolve(obj.stringProp);
>Promise.resolve(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>obj.stringProp : string
>obj : Obj
>stringProp : string
}
async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
>fIndexedTypeForExplicitPromiseOfStringProp : (obj: Obj) => Promise<string>
>obj : Obj
>Obj : Obj
>Promise : Promise<T>
>Obj : Obj
return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
>Promise.resolve<Obj["stringProp"]>(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Obj : Obj
>obj.stringProp : string
>obj : Obj
>stringProp : string
}
async function fIndexedTypeForAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
>fIndexedTypeForAnyProp : (obj: Obj) => Promise<any>
>obj : Obj
>Obj : Obj
>Promise : Promise<T>
>Obj : Obj
return obj.anyProp;
>obj.anyProp : any
>obj : Obj
>anyProp : any
}
async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
>fIndexedTypeForPromiseOfAnyProp : (obj: Obj) => Promise<any>
>obj : Obj
>Obj : Obj
>Promise : Promise<T>
>Obj : Obj
return Promise.resolve(obj.anyProp);
>Promise.resolve(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>obj.anyProp : any
>obj : Obj
>anyProp : any
}
async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
>fIndexedTypeForExplicitPromiseOfAnyProp : (obj: Obj) => Promise<any>
>obj : Obj
>Obj : Obj
>Promise : Promise<T>
>Obj : Obj
return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
>Promise.resolve<Obj["anyProp"]>(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Obj : Obj
>obj.anyProp : any
>obj : Obj
>anyProp : any
}
async function fGenericIndexedTypeForStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
>fGenericIndexedTypeForStringProp : <TObj extends Obj>(obj: TObj) => Promise<TObj["stringProp"]>
>TObj : TObj
>Obj : Obj
>obj : TObj
>TObj : TObj
>Promise : Promise<T>
>TObj : TObj
return obj.stringProp;
>obj.stringProp : string
>obj : TObj
>stringProp : string
}
async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
>fGenericIndexedTypeForPromiseOfStringProp : <TObj extends Obj>(obj: TObj) => Promise<TObj["stringProp"]>
>TObj : TObj
>Obj : Obj
>obj : TObj
>TObj : TObj
>Promise : Promise<T>
>TObj : TObj
return Promise.resolve(obj.stringProp);
>Promise.resolve(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>obj.stringProp : string
>obj : TObj
>stringProp : string
}
async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
>fGenericIndexedTypeForExplicitPromiseOfStringProp : <TObj extends Obj>(obj: TObj) => Promise<TObj["stringProp"]>
>TObj : TObj
>Obj : Obj
>obj : TObj
>TObj : TObj
>Promise : Promise<T>
>TObj : TObj
return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
>Promise.resolve<TObj["stringProp"]>(obj.stringProp) : Promise<TObj["stringProp"]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>TObj : TObj
>obj.stringProp : string
>obj : TObj
>stringProp : string
}
async function fGenericIndexedTypeForAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
>fGenericIndexedTypeForAnyProp : <TObj extends Obj>(obj: TObj) => Promise<TObj["anyProp"]>
>TObj : TObj
>Obj : Obj
>obj : TObj
>TObj : TObj
>Promise : Promise<T>
>TObj : TObj
return obj.anyProp;
>obj.anyProp : any
>obj : TObj
>anyProp : any
}
async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
>fGenericIndexedTypeForPromiseOfAnyProp : <TObj extends Obj>(obj: TObj) => Promise<TObj["anyProp"]>
>TObj : TObj
>Obj : Obj
>obj : TObj
>TObj : TObj
>Promise : Promise<T>
>TObj : TObj
return Promise.resolve(obj.anyProp);
>Promise.resolve(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>obj.anyProp : any
>obj : TObj
>anyProp : any
}
async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
>fGenericIndexedTypeForExplicitPromiseOfAnyProp : <TObj extends Obj>(obj: TObj) => Promise<TObj["anyProp"]>
>TObj : TObj
>Obj : Obj
>obj : TObj
>TObj : TObj
>Promise : Promise<T>
>TObj : TObj
return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
>Promise.resolve<TObj["anyProp"]>(obj.anyProp) : Promise<TObj["anyProp"]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>TObj : TObj
>obj.anyProp : any
>obj : TObj
>anyProp : any
}
async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K]>
>TObj : TObj
>Obj : Obj
>K : K
>TObj : TObj
>obj : TObj
>TObj : TObj
>key : K
>K : K
>Promise : Promise<T>
>TObj : TObj
>K : K
return obj[key];
>obj[key] : TObj[K]
>obj : TObj
>key : K
}
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForPromiseOfKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K]>
>TObj : TObj
>Obj : Obj
>K : K
>TObj : TObj
>obj : TObj
>TObj : TObj
>key : K
>K : K
>Promise : Promise<T>
>TObj : TObj
>K : K
return Promise.resolve(obj[key]);
>Promise.resolve(obj[key]) : Promise<TObj[K]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>obj[key] : TObj[K]
>obj : TObj
>key : K
}
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForExplicitPromiseOfKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K]>
>TObj : TObj
>Obj : Obj
>K : K
>TObj : TObj
>obj : TObj
>TObj : TObj
>key : K
>K : K
>Promise : Promise<T>
>TObj : TObj
>K : K
return Promise.resolve<TObj[K]>(obj[key]);
>Promise.resolve<TObj[K]>(obj[key]) : Promise<TObj[K]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>TObj : TObj
>K : K
>obj[key] : TObj[K]
>obj : TObj
>key : K
}

View File

@@ -8,3 +8,69 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
// This is contextually typed as a tuple.
return [1, true];
}
// https://github.com/Microsoft/TypeScript/issues/13128
interface Obj {
stringProp: string;
anyProp: any;
}
async function fIndexedTypeForStringProp(obj: Obj): Promise<Obj["stringProp"]> {
return obj.stringProp;
}
async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
return Promise.resolve(obj.stringProp);
}
async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
}
async function fIndexedTypeForAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
return obj.anyProp;
}
async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
return Promise.resolve(obj.anyProp);
}
async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
}
async function fGenericIndexedTypeForStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
return obj.stringProp;
}
async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
return Promise.resolve(obj.stringProp);
}
async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
}
async function fGenericIndexedTypeForAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
return obj.anyProp;
}
async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
return Promise.resolve(obj.anyProp);
}
async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
}
async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return obj[key];
}
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return Promise.resolve(obj[key]);
}
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return Promise.resolve<TObj[K]>(obj[key]);
}