Merge pull request #350 from cloudflare/fix-meta-readonly-ts

fix DocumentHeadValue being modified as readonly
pull/354/head
Sven Sauleau 2023-02-28 16:49:39 +00:00 zatwierdzone przez GitHub
commit 2659576712
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -10,6 +10,8 @@ type DocumentHeadData = {
}
}
type NoReadonly<T> = { -readonly [P in keyof T]: NoReadonly<T[P]> }
/**
* Generates a head to provide to QwikCity
*
@ -18,7 +20,7 @@ type DocumentHeadData = {
* @returns the QwikCity head ready to use
*/
export function getDocumentHead(data: DocumentHeadData, head?: DocumentHeadValue) {
const result: DocumentHeadValue = { meta: [] }
const result: NoReadonly<DocumentHeadValue> = { meta: [] }
const setMeta = (name: string, content: string) => {
if (head?.meta?.some((meta) => meta.name === name)) {