Skip to content

Commit 3547ec7

Browse files
Fix TypeScript linting issues in DocsSearch component
- Fixed string type checking for page.title - Added eslint-disable comments for manifest() type issues - Improved type safety in extractPages function Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
1 parent a643933 commit 3547ec7

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

docs-app/app/components/docs-search.gts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ function extractPages(pages: Page[], category = ''): PageData[] {
3333

3434
for (const page of pages) {
3535
if ('path' in page) {
36-
const title = 'title' in page && page.title ? String(page.title) : titleize(page.name);
36+
let title = titleize(page.name);
37+
38+
if ('title' in page && typeof page.title === 'string') {
39+
title = page.title;
40+
}
41+
3742
result.push({
3843
path: page.path,
3944
title,
@@ -42,7 +47,7 @@ function extractPages(pages: Page[], category = ''): PageData[] {
4247
}
4348

4449
if ('pages' in page && Array.isArray(page.pages)) {
45-
result.push(...extractPages(page.pages, titleize(page.name)));
50+
result.push(...extractPages(page.pages as Page[], titleize(page.name)));
4651
}
4752
}
4853

@@ -51,14 +56,19 @@ function extractPages(pages: Page[], category = ''): PageData[] {
5156

5257
export class DocsSearch extends Component {
5358
@service declare router: RouterService;
59+
5460
@tracked searchQuery = '';
61+
5562
@tracked isOpen = false;
5663

5764
get allPages(): PageData[] {
65+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
5866
const m = manifest();
67+
5968
if (!m) return [];
6069

61-
return extractPages(m.pages || []);
70+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
71+
return extractPages((m.pages || []) as Page[]);
6272
}
6373

6474
get filteredPages(): PageData[] {
@@ -67,6 +77,7 @@ export class DocsSearch extends Component {
6777
}
6878

6979
const query = this.searchQuery.toLowerCase();
80+
7081
return this.allPages
7182
.filter(
7283
(page) =>
@@ -79,6 +90,7 @@ export class DocsSearch extends Component {
7990

8091
handleInput = (event: Event) => {
8192
const target = event.target as HTMLInputElement;
93+
8294
this.searchQuery = target.value;
8395
};
8496

0 commit comments

Comments
 (0)