Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Nov 2, 2019
1 parent b1b0073 commit 3fa24c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3855,7 +3855,7 @@ namespace ts {
}
if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) {
if (type.flags & TypeFlags.TypeParameter && contains(context.inferTypeParameters, type)) {
context.approximateLength += (symbolName(type.symbol).length + 6);
context.approximateLength += 6 + (type.symbol ? symbolName(type.symbol).length : 1);
return createInferTypeNode(typeParameterToDeclarationWithConstraint(type as TypeParameter, context, /*constraintNode*/ undefined));
}
if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams &&
Expand Down Expand Up @@ -4791,7 +4791,7 @@ namespace ts {
return cached;
}
}
let result = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ true);
let result = type.symbol ? symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ true) : createIdentifier("?");
if (!(result.kind & SyntaxKind.Identifier)) {
return createIdentifier("(Missing type parameter)");
}
Expand Down
9 changes: 8 additions & 1 deletion tests/cases/compiler/asyncFunctionReturnType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends

async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
return Promise.resolve<TObj[K]>(obj[key]);
}
}

// #27711

async function fGeneric<T>(x: T) {
return x;
}
const result: Promise<number> = fGeneric(undefined as Promise<number>);

0 comments on commit 3fa24c7

Please sign in to comment.