@@ -21088,7 +21088,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2108821088 }
2108921089
2109021090 function hasContextSensitiveReturnExpression(node: FunctionLikeDeclaration) {
21091- if (node.typeParameters || getEffectiveReturnTypeNode(node) || !node.body) {
21091+ if (getEffectiveReturnTypeNode(node) || !node.body) {
2109221092 return false;
2109321093 }
2109421094 if (node.body.kind !== SyntaxKind.Block) {
@@ -26067,8 +26067,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2606726067 });
2606826068 }
2606926069
26070- function applyToParameterTypes(source: Signature, target: Signature, callback: (s: Type, t: Type) => void, skipUnannotatedParameters = false) {
26071- const sourceDeclaredCount = source.parameters.length - (signatureHasRestParameter(source) ? 1 : 0);
26070+ function applyToParameterTypes(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) {
2607226071 const sourceCount = getParameterCount(source);
2607326072 const targetCount = getParameterCount(target);
2607426073 const sourceRestType = getEffectiveRestType(source);
@@ -26083,12 +26082,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2608326082 }
2608426083 }
2608526084 for (let i = 0; i < paramCount; i++) {
26086- if (skipUnannotatedParameters) {
26087- const decl = i < sourceDeclaredCount ? source.parameters[i] : signatureHasRestParameter(source) ? source.parameters[sourceDeclaredCount] : undefined;
26088- if (decl?.valueDeclaration && !getEffectiveTypeAnnotationNode(decl.valueDeclaration)) {
26089- continue
26090- }
26091- }
2609226085 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
2609326086 }
2609426087 if (targetRestType) {
@@ -41383,7 +41376,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4138341376 const inferences = map(context.inferences, info => createInferenceInfo(info.typeParameter));
4138441377 applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => {
4138541378 inferTypes(inferences, source, target, /*priority*/ 0, /*contravariant*/ true);
41386- }, /*skipUnannotatedParameters*/ true );
41379+ });
4138741380 if (some(inferences, hasInferenceCandidates)) {
4138841381 // We have inference candidates, indicating that one or more type parameters are referenced
4138941382 // in the parameter types of the contextual signature. Now also infer from the return type.
@@ -41396,7 +41389,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4139641389 if (!hasOverlappingInferences(context.inferences, inferences)) {
4139741390 mergeInferences(context.inferences, inferences);
4139841391 context.inferredTypeParameters = concatenate(context.inferredTypeParameters, uniqueTypeParameters);
41399- assignContextualParameterTypes(signature, instantiateSignature(contextualSignature, context.mapper));
4140041392 return getOrCreateTypeFromSignature(instantiatedSignature);
4140141393 }
4140241394 }
@@ -41820,13 +41812,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4182041812 // or if its FunctionBody is strict code(11.1.5).
4182141813 checkGrammarModifiers(node);
4182241814
41823- if (getEffectiveTypeAnnotationNode(node)) {
41824- // checking annotated parameters early allows the compiler to find circularties early
41825- checkVariableLikeDeclaration(node);
41826- } else {
41827- // defer resolving the type of unannotated parameters so that late contextual parameter types can be assigned before it
41828- checkNodeDeferred(node);
41829- }
41815+ checkVariableLikeDeclaration(node);
4183041816 const func = getContainingFunction(node)!;
4183141817 if (hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
4183241818 if (compilerOptions.erasableSyntaxOnly) {
@@ -49172,9 +49158,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4917249158 case SyntaxKind.ClassExpression:
4917349159 checkClassExpressionDeferred(node as ClassExpression);
4917449160 break;
49175- case SyntaxKind.Parameter:
49176- checkVariableLikeDeclaration(node as ParameterDeclaration);
49177- break;
4917849161 case SyntaxKind.TypeParameter:
4917949162 checkTypeParameterDeferred(node as TypeParameterDeclaration);
4918049163 break;
0 commit comments