From c04b83ad41ca9c607f1675bd74f30ec790240092 Mon Sep 17 00:00:00 2001 From: Otavio Jacobi Date: Tue, 12 Mar 2024 10:18:55 -0300 Subject: [PATCH] Fix WebResource write typings Change-type: patch --- src/index.ts | 8 ++++++-- test/index.ts | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index f7e8817..11e0fce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,11 @@ export interface WebResource { size?: number; }; `, - write: '', + write: ` +export interface WebResourceWrite extends Blob { + name: string; +}; +`, }; const trimNL = new TemplateTag( @@ -116,7 +120,7 @@ const sqlTypeToTypescriptType = ( case 'JSON': return 'object'; case 'WebResource': - return 'WebResource'; + return opts.mode === 'read' ? 'WebResource' : 'WebResourceWrite'; default: throw new Error(`Unknown data type: '${f.dataType}'`); } diff --git a/test/index.ts b/test/index.ts index dc0e0f1..2722304 100644 --- a/test/index.ts +++ b/test/index.ts @@ -44,7 +44,13 @@ const test = ( ${expectation} `); } else { - expect(result).to.equal(expectation); + expect(result).to.equal(source` + export interface WebResourceWrite extends Blob { + name: string; + }; + + ${expectation} + `); } }); }; @@ -358,7 +364,7 @@ test( modified_at: Date; id: number; a_date: Date; - a_file: WebResource; + a_file: WebResourceWrite; parent: number; references__other: number; }