From cd00ee0539890187c863b35ec079127d7d4cec60 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 5 Jun 2024 20:07:14 +0100 Subject: [PATCH 1/2] fix(html): Correct types for the template function - Make templateoptions non-optional - Allow template to return a Promise Also adds type annotations to the implementation to ensure the types are more consistent. --- packages/html/src/index.ts | 9 +++------ packages/html/types/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/html/src/index.ts b/packages/html/src/index.ts index c22650057..59d74bfcd 100644 --- a/packages/html/src/index.ts +++ b/packages/html/src/index.ts @@ -70,7 +70,7 @@ const defaultTemplate = async ({ const supportedFormats = ['es', 'esm', 'iife', 'umd']; -const defaults = { +const defaults: Required = { attributes: { link: null, html: { lang: 'en' }, @@ -84,11 +84,8 @@ const defaults = { }; export default function html(opts: RollupHtmlOptions = {}): Plugin { - const { attributes, fileName, meta, publicPath, template, title } = Object.assign( - {}, - defaults, - opts - ); + const { attributes, fileName, meta, publicPath, template, title }: Required = + Object.assign({}, defaults, opts); return { name: 'html', diff --git a/packages/html/types/index.d.ts b/packages/html/types/index.d.ts index f8d62ef33..0b73a54f6 100644 --- a/packages/html/types/index.d.ts +++ b/packages/html/types/index.d.ts @@ -15,7 +15,7 @@ export interface RollupHtmlOptions { fileName?: string; meta?: Record[]; publicPath?: string; - template?: (templateoptions?: RollupHtmlTemplateOptions) => string; + template?: (templateoptions: RollupHtmlTemplateOptions) => string | Promise; } export function makeHtmlAttributes(attributes: Record): string; From 25955c782b23bab819c280b95e9c7f1377952698 Mon Sep 17 00:00:00 2001 From: shellscape Date: Sun, 15 Dec 2024 10:38:02 -0500 Subject: [PATCH 2/2] chore: correct types after bad conflict resolve --- packages/html/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/html/types/index.d.ts b/packages/html/types/index.d.ts index 715e9a03c..0b73a54f6 100644 --- a/packages/html/types/index.d.ts +++ b/packages/html/types/index.d.ts @@ -15,7 +15,7 @@ export interface RollupHtmlOptions { fileName?: string; meta?: Record[]; publicPath?: string; - template?: (templateoptions: RollupHtmlTemplateOptions) => string; + template?: (templateoptions: RollupHtmlTemplateOptions) => string | Promise; } export function makeHtmlAttributes(attributes: Record): string;