From 2d2ee155de7c601e98807882de4e8b0118d74f3e Mon Sep 17 00:00:00 2001 From: Hunter Larco Date: Tue, 19 Aug 2025 06:43:26 -0700 Subject: [PATCH] omit TProperty from role base inheritance --- packages/schema-dts-gen/src/ts/class.ts | 8 +++++++- .../test/baselines/role_inheritance_test.ts | 4 ++-- .../schema-dts-gen/test/baselines/role_simple_test.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/schema-dts-gen/src/ts/class.ts b/packages/schema-dts-gen/src/ts/class.ts index 8ff65b8..f7e4d4c 100644 --- a/packages/schema-dts-gen/src/ts/class.ts +++ b/packages/schema-dts-gen/src/ts/class.ts @@ -507,7 +507,13 @@ export class RoleBuiltin extends Builtin { ], /*type=*/ factory.createIntersectionTypeNode([ - factory.createTypeReferenceNode(baseName), + factory.createTypeReferenceNode( + /*typeName=*/ 'Omit', + /*typeArguments=*/ [ + factory.createTypeReferenceNode(baseName), + factory.createTypeReferenceNode(RoleBuiltin.kPropertyTypename), + ], + ), factory.createTypeLiteralNode([ new TypeProperty(this.subject).toNode(context), ]), diff --git a/packages/schema-dts-gen/test/baselines/role_inheritance_test.ts b/packages/schema-dts-gen/test/baselines/role_inheritance_test.ts index 713362a..ade863e 100644 --- a/packages/schema-dts-gen/test/baselines/role_inheritance_test.ts +++ b/packages/schema-dts-gen/test/baselines/role_inheritance_test.ts @@ -78,7 +78,7 @@ interface DateTimeLeaf extends DateTimeBase { } export type DateTime = DateTimeLeaf | string; -type OrganizationRoleLeaf = RoleBase & { +type OrganizationRoleLeaf = Omit & { "@type": "OrganizationRole"; } & { [key in TProperty]: TContent; @@ -88,7 +88,7 @@ export type OrganizationRole interface RoleBase extends ThingBase { "startDate"?: SchemaValue; } -type RoleLeaf = RoleBase & { +type RoleLeaf = Omit & { "@type": "Role"; } & { [key in TProperty]: TContent; diff --git a/packages/schema-dts-gen/test/baselines/role_simple_test.ts b/packages/schema-dts-gen/test/baselines/role_simple_test.ts index 37a7b3a..ee5d88b 100644 --- a/packages/schema-dts-gen/test/baselines/role_simple_test.ts +++ b/packages/schema-dts-gen/test/baselines/role_simple_test.ts @@ -78,7 +78,7 @@ export type DateTime = DateTimeLeaf | string; interface RoleBase extends ThingBase { "startDate"?: SchemaValue; } -type RoleLeaf = RoleBase & { +type RoleLeaf = Omit & { "@type": "Role"; } & { [key in TProperty]: TContent;