Skip to content

Commit

Permalink
Make a bit neater
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Hanson committed Dec 6, 2017
1 parent 2dec11c commit c8f70c4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17128,8 +17128,6 @@ namespace ts {
}

const { min: minArgumentCount, max: maxNonRestParam } = minAndMax(candidates, getNumNonRestParameters);
const hasRestParameter = candidates.some(c => c.hasRestParameter);
const hasLiteralTypes = candidates.some(c => c.hasLiteralTypes);
const parameters: ts.Symbol[] = [];
for (let i = 0; i < maxNonRestParam; i++) {
const symbols = mapDefined(candidates, ({ parameters, hasRestParameter }) => hasRestParameter ?
Expand All @@ -17139,23 +17137,23 @@ namespace ts {
parameters.push(createCombinedSymbolFromTypes(symbols, mapDefined(candidates, candidate => tryGetTypeAtPosition(candidate, i))));
}

const restParameterSymbols = mapDefined(candidates, c => c.hasRestParameter ? last(c.parameters) : undefined);
const hasRestParameter = restParameterSymbols.length !== 0;
if (hasRestParameter) {
const symbols = mapDefined(candidates, c => c.hasRestParameter ? last(c.parameters) : undefined);
Debug.assert(symbols.length !== 0);
const type = createArrayType(getUnionType(mapDefined(candidates, tryGetRestTypeOfSignature), /*subtypeReduction*/ true));
parameters.push(createCombinedSymbolForOverloadFailure(symbols, type));
parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
}

return createSignature(
candidates[0].declaration,
/*typeParameters*/ undefined,
/*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`.
thisParameter,
parameters,
/*resolvedReturnType*/ unknownType,
/*typePredicate*/ undefined,
minArgumentCount,
hasRestParameter,
hasLiteralTypes);
/*hasLiteralTypes*/ candidates.some(c => c.hasLiteralTypes));
}

function createCombinedSymbolFromTypes(sources: ReadonlyArray<Symbol>, types: ReadonlyArray<Type>): Symbol {
Expand Down

0 comments on commit c8f70c4

Please sign in to comment.