Skip to content

Commit ed9cbf3

Browse files
LeoMcAcaugner
andauthored
fix(types): pass types through memoize properly (#10567)
Co-authored-by: Claas Augner <[email protected]>
1 parent e606646 commit ed9cbf3

File tree

7 files changed

+201
-172
lines changed

7 files changed

+201
-172
lines changed

Diff for: build/blog.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export async function buildBlogPosts(options: {
281281

282282
const url = `/${locale}/blog/${blogMeta.slug}/`;
283283
const renderUrl = `/${locale}/blog/${blogMeta.slug}`;
284-
const renderDoc = {
284+
const renderDoc: BlogPostDoc = {
285285
url: renderUrl,
286286
rawBody: body,
287287
metadata: { locale, ...blogMeta },
@@ -344,11 +344,11 @@ export async function buildBlogPosts(options: {
344344
}
345345
}
346346

347-
interface BlogPostDoc {
347+
export interface BlogPostDoc {
348348
url: string;
349349
rawBody: string;
350350
metadata: BlogPostMetadata & { locale: string };
351-
isMarkdown: boolean;
351+
isMarkdown: true;
352352
fileInfo: {
353353
path: string;
354354
};
@@ -368,7 +368,7 @@ export async function buildPost(
368368
let $ = null;
369369
const liveSamples: LiveSample[] = [];
370370

371-
[$] = await kumascript.render(document.url, {}, document as any);
371+
[$] = await kumascript.render(document.url, {}, document);
372372

373373
const liveSamplePages = await kumascript.buildLiveSamplePages(
374374
document.url,
@@ -449,8 +449,12 @@ export async function buildBlogFeed(options: { verbose?: boolean }) {
449449
description: post.description,
450450
author: [
451451
{
452-
name: post.author?.name || "The MDN Team",
453-
link: post.author?.link,
452+
name:
453+
(typeof post.author === "string"
454+
? post.author
455+
: post.author?.name) || "The MDN Team",
456+
link:
457+
typeof post.author === "string" ? post.author : post.author?.link,
454458
},
455459
],
456460
date: new Date(post.date),

Diff for: build/curriculum.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { memoize, slugToFolder } from "../content/utils.js";
4040
import { renderHTML } from "../ssr/dist/main.js";
4141
import { CheerioAPI } from "cheerio";
4242

43-
export const allFiles: () => string[] = memoize(async () => {
43+
export const allFiles = memoize(async () => {
4444
const api = new fdir()
4545
.withFullPaths()
4646
.withErrors()
@@ -49,7 +49,7 @@ export const allFiles: () => string[] = memoize(async () => {
4949
return (await api.withPromise()).sort();
5050
});
5151

52-
export const buildIndex: () => CurriculumMetaData[] = memoize(async () => {
52+
export const buildIndex = memoize(async () => {
5353
const files = await allFiles();
5454
const modules = await Promise.all(
5555
files.map(

0 commit comments

Comments
 (0)