Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): pass types through memoize properly #10567

Merged
merged 6 commits into from
Mar 5, 2024
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
16 changes: 10 additions & 6 deletions build/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export async function buildBlogPosts(options: {

const url = `/${locale}/blog/${blogMeta.slug}/`;
const renderUrl = `/${locale}/blog/${blogMeta.slug}`;
const renderDoc = {
const renderDoc: BlogPostDoc = {
url: renderUrl,
rawBody: body,
metadata: { locale, ...blogMeta },
Expand Down Expand Up @@ -344,11 +344,11 @@ export async function buildBlogPosts(options: {
}
}

interface BlogPostDoc {
export interface BlogPostDoc {
url: string;
rawBody: string;
metadata: BlogPostMetadata & { locale: string };
isMarkdown: boolean;
isMarkdown: true;
fileInfo: {
path: string;
};
Expand All @@ -368,7 +368,7 @@ export async function buildPost(
let $ = null;
const liveSamples: LiveSample[] = [];

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

const liveSamplePages = await kumascript.buildLiveSamplePages(
document.url,
Expand Down Expand Up @@ -449,8 +449,12 @@ export async function buildBlogFeed(options: { verbose?: boolean }) {
description: post.description,
author: [
{
name: post.author?.name || "The MDN Team",
link: post.author?.link,
name:
(typeof post.author === "string"
? post.author
: post.author?.name) || "The MDN Team",
link:
typeof post.author === "string" ? post.author : post.author?.link,
},
],
date: new Date(post.date),
Expand Down
4 changes: 2 additions & 2 deletions build/curriculum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { memoize, slugToFolder } from "../content/utils.js";
import { renderHTML } from "../ssr/dist/main.js";
import { CheerioAPI } from "cheerio";

export const allFiles: () => string[] = memoize(async () => {
export const allFiles = memoize(async () => {
const api = new fdir()
.withFullPaths()
.withErrors()
Expand All @@ -49,7 +49,7 @@ export const allFiles: () => string[] = memoize(async () => {
return (await api.withPromise()).sort();
});

export const buildIndex: () => CurriculumMetaData[] = memoize(async () => {
export const buildIndex = memoize(async () => {
const files = await allFiles();
const modules = await Promise.all(
files.map(
Expand Down
Loading
Loading