Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b062715

Browse files
harlan-zwCopilot
andauthored
fix(types): make templateParams extensible via module augmentation (#679)
* fix(types): make templateParams extensible via module augmentation Add `templateParams` to `SchemaAugmentations` and intersect it into `ResolvableTemplateParams`, allowing users to extend templateParams via `declare module 'unhead/types' { interface SchemaAugmentations { templateParams: { foo: string } } }`. Also updates `ReactiveHead.templateParams` in the Vue package to use the shared `ResolvableTemplateParams` type. Closes #575 * fix(types): make templateParams extensible via module augmentation (#684) * Initial plan * fix(types): use dedicated TemplateParamsAugmentations interface to avoid TS2717 Co-authored-by: harlan-zw <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: harlan-zw <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: harlan-zw <[email protected]>
1 parent beeb5f1 commit b062715

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/unhead/src/types/schema/head.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ import type {
7373
} from './script'
7474
import type { Style } from './style'
7575

76+
export interface TemplateParamsAugmentations {}
77+
7678
export interface SchemaAugmentations {
7779
title: TagPriority
7880
titleTemplate: TagPriority
@@ -147,7 +149,7 @@ export type ResolvableScript = DistributeResolvableWithEvents<Script, SchemaAugm
147149
export type ResolvableNoscript = ResolvableProperties<Noscript & DataKeys & SchemaAugmentations['noscript']> | string
148150
export type ResolvableHtmlAttributes = ResolvableProperties<UnheadHtmlAttributes & DataKeys & SchemaAugmentations['htmlAttrs']>
149151
export type ResolvableBodyAttributes = ResolvableProperties<UnheadBodyAttributesWithoutEvents & DataKeys & SchemaAugmentations['bodyAttrs']> & MaybeEventFnHandlers<BodyEvents>
150-
export type ResolvableTemplateParams = { separator?: '|' | '-' | '·' | string } & Record<string, null | string | Record<string, string>>
152+
export type ResolvableTemplateParams = { separator?: '|' | '-' | '·' | string } & Record<string, null | string | Record<string, string>> & TemplateParamsAugmentations
151153

152154
export interface ResolvableHead {
153155
/**

packages/vue/src/types/schema.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
MaybeEventFnHandlers,
1313
MetaFlat,
1414
Noscript,
15+
ResolvableTemplateParams,
1516
SchemaAugmentations,
1617
Script,
1718
ScriptHttpEvents,
@@ -85,10 +86,7 @@ export interface ReactiveHead {
8586
/**
8687
* Variables used to substitute in the title and meta content.
8788
*/
88-
templateParams?: ResolvableProperties<
89-
{ separator?: '|' | '-' | '·' | string }
90-
& Record<string, Stringable | ResolvableProperties<Record<string, Stringable>>>
91-
>
89+
templateParams?: ResolvableProperties<ResolvableTemplateParams>
9290
/**
9391
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
9492
* There can be only one <base> element in a document.

0 commit comments

Comments
 (0)