From a462d705c3a060348ebb8618ea3d93e15de3d16f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:39:39 +0000 Subject: [PATCH 1/2] Initial plan for issue From f1c7014896fe7fb221a27c1d1cb5e1f72e5ff44b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:56:20 +0000 Subject: [PATCH 2/2] Port TypeScript PR #60083: Don't issue implicit any when obtaining implied type for binding pattern Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com> --- internal/checker/checker.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 65a23fce6d..6085378c92 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -15969,6 +15969,10 @@ func (c *Checker) padTupleType(t *Type, pattern *ast.Node) *Type { } func (c *Checker) widenTypeInferredFromInitializer(declaration *ast.Node, t *Type) *Type { + return c.getWidenedLiteralTypeForInitializer(declaration, t) +} + +func (c *Checker) getWidenedLiteralTypeForInitializer(declaration *ast.Node, t *Type) *Type { if c.getCombinedNodeFlagsCached(declaration)&ast.NodeFlagsConstant != 0 || isDeclarationReadonly(declaration) { return t } @@ -17089,7 +17093,7 @@ func (c *Checker) getTypeFromBindingElement(element *ast.Node, includePatternInT if ast.IsBindingPattern(element.Name()) { contextualType = c.getTypeFromBindingPattern(element.Name(), true /*includePatternInType*/, false /*reportErrors*/) } - return c.addOptionality(c.widenTypeInferredFromInitializer(element, c.checkDeclarationInitializer(element, CheckModeNormal, contextualType))) + return c.addOptionality(c.getWidenedLiteralTypeForInitializer(element, c.checkDeclarationInitializer(element, CheckModeNormal, contextualType))) } if ast.IsBindingPattern(element.Name()) { return c.getTypeFromBindingPattern(element.Name(), includePatternInType, reportErrors)