Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions type-tests/processed-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type HtmlRspackPlugin from '../typings';

type Equal<A, B> =
(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
? true
: false;
type Assert<T extends true> = 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<Equal<ProcessedOptions['title'], string>>,
Assert<Equal<Pick<ProcessedOptions, 'minify'>, Pick<Options, 'minify'>>>,
];
6 changes: 4 additions & 2 deletions typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ declare namespace HtmlRspackPlugin {
/**
* The plugin options after adding default values
*/
type ProcessedOptions = Required<Omit<Options, 'minify'>> &
Pick<Options, 'minify'>;
type ProcessedOptions = {
// Preserve named properties alongside the index signature in Options.
[K in keyof Options as Exclude<K, 'minify'>]-?: Options[K];
} & Pick<Options, 'minify'>;

/**
* The values which are available during template execution
Expand Down
Loading