Skip to content

Commit

Permalink
Ensure createTupleType([]) to return singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
lefb766 committed Mar 20, 2017
1 parent 61ac5be commit e02dcf3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6210,7 +6210,13 @@ namespace ts {
return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity));
}

function createTupleType(elementTypes: Type[]) {
function createTupleType(elementTypes: Type[]): TypeReference {
// We have to ensure that we get same instance for empty tuple type,
// because we use === in isTupleLikeType(type).
if (!elementTypes.length && emptyTupleType) {
return emptyTupleType;
}

return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes);
}

Expand Down

0 comments on commit e02dcf3

Please sign in to comment.