fix(53933): Confusing rules around function parameter names in a type (#53946)

This commit is contained in:
Oleksandr T
2023-10-30 15:24:14 -04:00
committed by GitHub
parent d7c2670898
commit 60ce788302
6 changed files with 33 additions and 11 deletions
+1 -1
View File
@@ -42152,7 +42152,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
forEach(node.name.elements, checkSourceElement);
}
// For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body
if (isParameter(node) && node.initializer && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) {
if (node.initializer && isParameterDeclaration(node) && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) {
error(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
return;
}