From 04b5daa2fe5c2f9dfa982922ec297a062052f46c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 31 Aug 2026 19:29:39 +0000 Subject: [PATCH 1/2] Initial plan From b8f2599cf37ef4b68047012bb5ecad52c0b70585 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 31 Aug 2026 19:44:02 +0000 Subject: [PATCH 2/2] Fix printing mapped types without property types Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> --- .../hoverMappedTypePropertyJSDoc_test.go | 11 +++++ tsc/internal/printer/printer.go | 8 ++-- ...overMappedTypeWithoutPropertyType.baseline | 41 +++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 tsc/testdata/baselines/reference/fourslash/quickInfo/hoverMappedTypeWithoutPropertyType.baseline diff --git a/tsc/internal/fourslash/tests/hoverMappedTypePropertyJSDoc_test.go b/tsc/internal/fourslash/tests/hoverMappedTypePropertyJSDoc_test.go index 37398b3e11b75..1b79314469901 100644 --- a/tsc/internal/fourslash/tests/hoverMappedTypePropertyJSDoc_test.go +++ b/tsc/internal/fourslash/tests/hoverMappedTypePropertyJSDoc_test.go @@ -35,3 +35,14 @@ A.X/*2*/; defer done() f.VerifyBaselineHover(t) } + +func TestHoverMappedTypeWithoutPropertyType(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` +declare function uhoh/*1*/(x: { [K in keyof T] }): void; +` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineHover(t) +} diff --git a/tsc/internal/printer/printer.go b/tsc/internal/printer/printer.go index ae279d9666341..ac8f4353dc668 100644 --- a/tsc/internal/printer/printer.go +++ b/tsc/internal/printer/printer.go @@ -2181,9 +2181,11 @@ func (p *Printer) emitMappedType(node *ast.MappedTypeNode) { p.writePunctuation("?") } } - p.writePunctuation(":") - p.writeSpace() - p.emitTypeNodeOutsideExtends(node.Type) + if node.Type != nil { + p.writePunctuation(":") + p.writeSpace() + p.emitTypeNodeOutsideExtends(node.Type) + } p.writeTrailingSemicolon() if node.Members != nil { if len(node.Members.Nodes) > 0 { diff --git a/tsc/testdata/baselines/reference/fourslash/quickInfo/hoverMappedTypeWithoutPropertyType.baseline b/tsc/testdata/baselines/reference/fourslash/quickInfo/hoverMappedTypeWithoutPropertyType.baseline new file mode 100644 index 0000000000000..7941d30d1a03f --- /dev/null +++ b/tsc/testdata/baselines/reference/fourslash/quickInfo/hoverMappedTypeWithoutPropertyType.baseline @@ -0,0 +1,41 @@ +// === QuickInfo === +=== /hoverMappedTypeWithoutPropertyType.ts === +// +// declare function uhoh(x: { [K in keyof T] }): void; +// ^^^^ +// | ---------------------------------------------------------------------- +// | ```typescript +// | function uhoh(x: { [K in keyof T]; }): void +// | ``` +// | +// | ---------------------------------------------------------------------- +// +[ + { + "marker": { + "Position": 22, + "LSPosition": { + "line": 1, + "character": 21 + }, + "Name": "1", + "Data": {} + }, + "item": { + "contents": { + "kind": "markdown", + "value": "```typescript\nfunction uhoh(x: { [K in keyof T]; }): void\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 17 + }, + "end": { + "line": 1, + "character": 21 + } + } + } + } +] \ No newline at end of file