From 43f8449c100d5e0ce2306b7eed3f4e1679615a41 Mon Sep 17 00:00:00 2001 From: Steve Konves Date: Wed, 12 Nov 2025 20:21:45 -0700 Subject: [PATCH] fix(#139): support nullable map property values --- packages/typescript/src/interface-factory.ts | 2 +- .../4.1-structure/4.1.12-primitive-value.spec.ts | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/typescript/src/interface-factory.ts b/packages/typescript/src/interface-factory.ts index f7ceea3..62238fa 100644 --- a/packages/typescript/src/interface-factory.ts +++ b/packages/typescript/src/interface-factory.ts @@ -289,7 +289,7 @@ function* buildType(type: Type): Iterable { const recordType = `Record<${keyTypeName}, ${Array.from(typeNames) .sort() - .join(' | ')}>`; + .join(' | ')} ${mapValue.value.isNullable ? ` | null` : ''}>`; yield isEnumKey ? `Partial<${recordType}>` : recordType; } diff --git a/packages/typescript/src/spec/4.1-structure/4.1.12-primitive-value.spec.ts b/packages/typescript/src/spec/4.1-structure/4.1.12-primitive-value.spec.ts index 02ccf95..710317d 100644 --- a/packages/typescript/src/spec/4.1-structure/4.1.12-primitive-value.spec.ts +++ b/packages/typescript/src/spec/4.1-structure/4.1.12-primitive-value.spec.ts @@ -241,9 +241,7 @@ describe('4.1.12 Primitive Value', () => { ); }); - // TODO: fix and enable these tests - // https://github.com/basketry/typescript/issues/139 - describe.skip('map property value', () => { + describe('map property value', () => { it.each(typeMap)( 'emits nullable `%s` as a union of `%s` and null', async (primitive, expectedType) => { @@ -407,9 +405,7 @@ describe('4.1.12 Primitive Value', () => { ); }); - // TODO: fix and enable these tests - // https://github.com/basketry/typescript/issues/139 - describe.skip('map property value', () => { + describe('map property value', () => { it.each(typeMap)( 'emits `%s` as a union of `%s` array and null', async (primitive, expectedType) => { @@ -577,9 +573,7 @@ describe('4.1.12 Primitive Value', () => { ); }); - // TODO: fix and enable these tests - // https://github.com/basketry/typescript/issues/139 - describe.skip('map property value', () => { + describe('map property value', () => { it.each(typeMap)( 'emits nullable `%s` as a union of `%s` and null', async (primitive, expectedType) => { @@ -665,9 +659,7 @@ describe('4.1.12 Primitive Value', () => { ); }); - // TODO: fix and enable these tests - // https://github.com/basketry/typescript/issues/139 - describe.skip('map property value', () => { + describe('map property value', () => { it.each(typeMap)( 'emits `%s` as a union of `%s` array and null', async (primitive, expectedType) => {