Skip to content

Commit 611474f

Browse files
committed
fix(website): resolve TypeScript errors in samples.ts
- Remove SearchableRecipe interface that conflicted with SearchableItem - Use proper type casting for search results - Fix FuzzySearch generic type usage
1 parent f8d9322 commit 611474f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

website/src/scripts/pages/samples.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface RecipeVariant {
1919
example: string | null;
2020
}
2121

22-
interface Recipe extends SearchableItem {
22+
interface Recipe {
2323
id: string;
2424
name: string;
2525
description: string;
@@ -49,7 +49,7 @@ interface SamplesData {
4949

5050
// State
5151
let samplesData: SamplesData | null = null;
52-
let search: FuzzySearch<Recipe & { title: string; cookbookId: string }> | null = null;
52+
let search: FuzzySearch<SearchableItem> | null = null;
5353
let selectedLanguage: string | null = null;
5454
let selectedTags: string[] = [];
5555
let expandedRecipes: Set<string> = new Set();
@@ -73,7 +73,7 @@ export async function initSamplesPage(): Promise<void> {
7373
...recipe,
7474
title: recipe.name,
7575
cookbookId: cookbook.id
76-
}))
76+
} as SearchableItem & { cookbookId: string }))
7777
);
7878
search = new FuzzySearch(allRecipes);
7979

@@ -212,14 +212,15 @@ function getFilteredRecipes(): { cookbook: Cookbook; recipe: Recipe; highlighted
212212
let results: { cookbook: Cookbook; recipe: Recipe; highlighted?: string }[] = [];
213213

214214
if (query) {
215-
// Use fuzzy search
215+
// Use fuzzy search - returns SearchableItem[] directly
216216
const searchResults = search.search(query);
217-
results = searchResults.map(result => {
218-
const cookbook = samplesData!.cookbooks.find(c => c.id === result.item.cookbookId)!;
217+
results = searchResults.map(item => {
218+
const recipe = item as SearchableItem & { cookbookId: string };
219+
const cookbook = samplesData!.cookbooks.find(c => c.id === recipe.cookbookId)!;
219220
return {
220221
cookbook,
221-
recipe: result.item,
222-
highlighted: search!.highlight(result.item.title, query)
222+
recipe: recipe as unknown as Recipe,
223+
highlighted: search!.highlight(recipe.title, query)
223224
};
224225
});
225226
} else {

0 commit comments

Comments
 (0)