diff --git a/type-tests/processed-options.ts b/type-tests/processed-options.ts new file mode 100644 index 0000000..f42b8e6 --- /dev/null +++ b/type-tests/processed-options.ts @@ -0,0 +1,17 @@ +import type HtmlRspackPlugin from '../typings'; + +type Equal = + (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 + ? true + : false; +type Assert = T; + +type Options = HtmlRspackPlugin.Options; +type ProcessedOptions = HtmlRspackPlugin.ProcessedOptions; + +// Runtime tests cannot detect options degrading to any. Check a named option +// and keep minify optional to guard against regressions in ProcessedOptions. +export type ProcessedOptionsAssertions = [ + Assert>, + Assert, Pick>>, +]; diff --git a/typings.d.ts b/typings.d.ts index 780340a..e8a0901 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -171,8 +171,10 @@ declare namespace HtmlRspackPlugin { /** * The plugin options after adding default values */ - type ProcessedOptions = Required> & - Pick; + type ProcessedOptions = { + // Preserve named properties alongside the index signature in Options. + [K in keyof Options as Exclude]-?: Options[K]; + } & Pick; /** * The values which are available during template execution