From 03e998b714de9497fef2eea778672b8a2952f926 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Tue, 12 Mar 2024 11:34:43 +0000 Subject: [PATCH] Fix generated write typings when `WebResource` are included Change-type: patch --- src/index.ts | 19 +++++++++++-------- test/index.ts | 12 +++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index f7e8817..bd3efcf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,13 @@ type RequiredModelSubset = Pick< 'tables' | 'relationships' | 'synonyms' >; +const webResource = `export interface WebResource { + filename: string; + href: string; + content_type?: string; + content_disposition?: string; + size?: number; +};`; const typeHelpers = { read: ` export type DateString = string; @@ -29,15 +36,11 @@ export type Deferred = Exclude; export type PickDeferred = { [P in K]: Deferred; }; -export interface WebResource { - filename: string; - href: string; - content_type?: string; - content_disposition?: string; - size?: number; -}; +${webResource} +`, + write: ` +${webResource} `, - write: '', }; const trimNL = new TemplateTag( diff --git a/test/index.ts b/test/index.ts index dc0e0f1..b46c065 100644 --- a/test/index.ts +++ b/test/index.ts @@ -44,7 +44,17 @@ const test = ( ${expectation} `); } else { - expect(result).to.equal(expectation); + expect(result).to.equal(source` + export interface WebResource { + filename: string; + href: string; + content_type?: string; + content_disposition?: string; + size?: number; + }; + + ${expectation} + `); } }); };