From e520b327c1fce28a1764e17368556b5db3256ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kuna?= <1282324+codecalm@users.noreply.github.com> Date: Sat, 8 Aug 2026 01:27:03 +0200 Subject: [PATCH] Enable `astro/tsconfigs/strictest` in the shared package (#2836) --- shared/components/cards/AuthLockCard.astro | 3 +- shared/components/cards/Card.astro | 7 ++-- shared/components/cards/CardImage.astro | 3 +- shared/components/cards/CarouselCard.astro | 1 - shared/components/cards/ProjectProgress.astro | 3 +- shared/components/cards/Subscribe.astro | 3 +- shared/components/cards/UserCard.astro | 3 +- shared/components/cards/UserCardBg.astro | 5 ++- shared/components/cards/UserCardBig.astro | 3 +- shared/components/cards/UserInfo.astro | 3 +- shared/components/cards/UsersList2.astro | 7 ++-- shared/components/cards/music/TrackInfo.astro | 6 ++- .../components/cards/music/TracksList.astro | 3 +- .../layout/HeaderActionsButtons.astro | 2 +- shared/components/layout/HeaderProfile.astro | 3 +- shared/components/layout/PageHeader.astro | 12 +++--- .../components/marketing/SectionDivider.astro | 2 +- .../modals/AddTaskModalContent.astro | 3 +- .../modals/ChangePasswordModalContent.astro | 4 +- shared/components/navbar/Navbar.astro | 14 +++---- shared/components/navbar/NavbarMenu.astro | 2 +- shared/components/navbar/NavbarSide.astro | 2 +- shared/components/navbar/NavbarSideUser.astro | 3 +- shared/components/navbar/Sidebar.astro | 8 ++-- shared/components/parts/Datagrid.astro | 3 +- shared/layouts/BaseLayout.astro | 8 ++-- shared/layouts/DefaultLayout.astro | 14 +++---- shared/lib/chart-script.ts | 2 +- shared/lib/pseudo-random.ts | 4 +- shared/lib/string-format.test.ts | 3 +- shared/tsconfig.json | 2 +- shared/ui/AdvancedTable.astro | 39 ++++++++++++------- shared/ui/Avatar.astro | 6 +-- shared/ui/AvatarList.astro | 4 +- shared/ui/BackgroundPattern.astro | 2 +- shared/ui/Badge.astro | 1 - shared/ui/Button.astro | 2 +- shared/ui/Card.astro | 2 +- shared/ui/CardHeader.astro | 4 +- shared/ui/CardSubtitle.astro | 2 +- shared/ui/CardTitle.astro | 4 +- shared/ui/ChartSparkline.astro | 4 +- shared/ui/Chat.astro | 3 +- shared/ui/Empty.astro | 6 +-- shared/ui/Flag.astro | 2 +- shared/ui/FormHint.astro | 6 +-- shared/ui/Icon.astro | 4 +- shared/ui/ListGroup.astro | 2 +- shared/ui/ListGroupItem.astro | 2 +- shared/ui/Photo.astro | 2 +- shared/ui/Progress.astro | 6 +-- shared/ui/ProgressDescription.astro | 2 +- shared/ui/Select.astro | 2 +- shared/ui/Subheader.astro | 2 +- shared/ui/Timeline.astro | 8 ++-- shared/ui/Toast.astro | 3 +- shared/ui/Trending.astro | 2 +- 57 files changed, 147 insertions(+), 116 deletions(-) diff --git a/shared/components/cards/AuthLockCard.astro b/shared/components/cards/AuthLockCard.astro index 1877a6f1f..e2a136763 100644 --- a/shared/components/cards/AuthLockCard.astro +++ b/shared/components/cards/AuthLockCard.astro @@ -3,8 +3,9 @@ import Button from '@ui/Button.astro' import Avatar from '@ui/Avatar.astro' import CardTitle from '@ui/CardTitle.astro' import people from '@data/people.json' +import { requireIndex } from '@shared/lib/array' -const person = people[0] +const person = requireIndex(people, 0) ---
diff --git a/shared/components/cards/Card.astro b/shared/components/cards/Card.astro index e58b7ed64..6f504bcc3 100644 --- a/shared/components/cards/Card.astro +++ b/shared/components/cards/Card.astro @@ -5,6 +5,7 @@ import AvatarList from '@ui/AvatarList.astro'; import Empty from '@ui/Empty.astro'; import Progress from '@ui/Progress.astro'; import photos from '@data/photos.json'; +import { requireIndex } from '@shared/lib/array'; interface Props { link?: boolean; @@ -61,7 +62,7 @@ const { footerButtons, footerElements, progress, -} = Astro.props; +}: Props = Astro.props; const Element = link ? 'a' : 'div'; @@ -86,8 +87,8 @@ const footerEls = (footerElements ?? []).map((element: string) => { const hasHeader = header || headerTitle || headerTabs || headerPills; const hasFooter = footer || footerButton || footerButtons || footerElements; -const imgTopPhoto = (photos as { file: string; title: string }[])[7]; -const imgBottomPhoto = (photos as { file: string; title: string }[])[11]; +const imgTopPhoto = requireIndex(photos as { file: string; title: string }[], 7); +const imgBottomPhoto = requireIndex(photos as { file: string; title: string }[], 11); --- diff --git a/shared/components/cards/CardImage.astro b/shared/components/cards/CardImage.astro index 903ce51d5..0962cc1bb 100644 --- a/shared/components/cards/CardImage.astro +++ b/shared/components/cards/CardImage.astro @@ -1,5 +1,6 @@ --- import photos from '@data/photos.json' +import { requireIndex } from '@shared/lib/array' interface Props { title?: string @@ -9,7 +10,7 @@ interface Props { const { title, right, imgId = 1 } = Astro.props -const photo = (photos as { file: string; title: string }[])[imgId] +const photo = requireIndex(photos as { file: string; title: string }[], imgId) const imgClass = `w-100 h-100 object-cover ${right ? 'card-img-end' : 'card-img-start'}` --- diff --git a/shared/components/cards/CarouselCard.astro b/shared/components/cards/CarouselCard.astro index 0b2089c6c..6d7736c68 100644 --- a/shared/components/cards/CarouselCard.astro +++ b/shared/components/cards/CarouselCard.astro @@ -2,7 +2,6 @@ // Photos filtered to horizontal=true, then sliced by offset/limit. import photos from '@data/photos.json' import CardTitle from '@ui/CardTitle.astro' -import Carousel from '@ui/Carousel.astro' interface Props { id?: string diff --git a/shared/components/cards/ProjectProgress.astro b/shared/components/cards/ProjectProgress.astro index 021aa0c23..75047fd0f 100644 --- a/shared/components/cards/ProjectProgress.astro +++ b/shared/components/cards/ProjectProgress.astro @@ -2,6 +2,7 @@ import Progress from '@ui/Progress.astro' import CardDropdown from '@ui/CardDropdown.astro' import projects from '@data/projects.json' +import { requireIndex } from '@shared/lib/array' interface Project { title?: string @@ -16,7 +17,7 @@ interface Props { } const { projectId = 0, progress = 25, daysAgo = 2 } = Astro.props -const project = (projects as Project[])[projectId] +const project = requireIndex(projects as Project[], projectId) ---
diff --git a/shared/components/cards/Subscribe.astro b/shared/components/cards/Subscribe.astro index 762a5c99b..887d46054 100644 --- a/shared/components/cards/Subscribe.astro +++ b/shared/components/cards/Subscribe.astro @@ -2,6 +2,7 @@ import Avatar from '@ui/Avatar.astro' import CardDropdown from '@ui/CardDropdown.astro' import people from '@data/people.json' +import { requireIndex } from '@shared/lib/array' interface Person { full_name?: string @@ -15,7 +16,7 @@ interface Props { } const { personId = 0 } = Astro.props -const person = (people as Person[])[personId] +const person = requireIndex(people as Person[], personId) ---
diff --git a/shared/components/cards/UserCard.astro b/shared/components/cards/UserCard.astro index 09b89fc52..ad6f371ef 100644 --- a/shared/components/cards/UserCard.astro +++ b/shared/components/cards/UserCard.astro @@ -2,6 +2,7 @@ // person = people[person-id] (no -1: the object is passed straight to Avatar). import Avatar from '@ui/Avatar.astro' import people from '@data/people.json' +import { requireIndex } from '@shared/lib/array' interface Person { full_name?: string @@ -16,7 +17,7 @@ interface Props { } const { personId = 0, right } = Astro.props -const person = (people as Person[])[personId] +const person = requireIndex(people as Person[], personId) --- diff --git a/shared/components/cards/UserCardBg.astro b/shared/components/cards/UserCardBg.astro index bec5b7f4d..d377a0d13 100644 --- a/shared/components/cards/UserCardBg.astro +++ b/shared/components/cards/UserCardBg.astro @@ -3,6 +3,7 @@ import Avatar from '@ui/Avatar.astro' import people from '@data/people.json' import photos from '@data/photos.json' +import { requireIndex } from '@shared/lib/array' interface Person { full_name?: string @@ -22,8 +23,8 @@ interface Props { } const { personId = 0, blurred } = Astro.props -const person = (people as Person[])[personId] -const photo = (photos as Photo[])[personId] +const person = requireIndex(people as Person[], personId) +const photo = requireIndex(photos as Photo[], personId) --- diff --git a/shared/components/cards/UserCardBig.astro b/shared/components/cards/UserCardBig.astro index 4cf2f96b6..15c834b05 100644 --- a/shared/components/cards/UserCardBig.astro +++ b/shared/components/cards/UserCardBig.astro @@ -1,6 +1,7 @@ --- import Avatar from '@ui/Avatar.astro' import people from '@data/people.json' +import { requireIndex } from '@shared/lib/array' interface Person { full_name?: string @@ -14,7 +15,7 @@ interface Props { } const { personId = 0 } = Astro.props -const person = (people as Person[])[personId] +const person = requireIndex(people as Person[], personId) ---
diff --git a/shared/components/cards/UserInfo.astro b/shared/components/cards/UserInfo.astro index 44ef57e79..89833666a 100644 --- a/shared/components/cards/UserInfo.astro +++ b/shared/components/cards/UserInfo.astro @@ -3,6 +3,7 @@ import Icon from '@ui/Icon.astro' import Flag from '@ui/Flag.astro' import people from '@data/people.json' +import { requireIndex } from '@shared/lib/array' interface Person { university?: string @@ -21,7 +22,7 @@ interface Props { } const { title = 'Basic info', personId = 25 } = Astro.props -const person = (people as Person[])[personId - 1] +const person = requireIndex(people as Person[], personId - 1) ---
diff --git a/shared/components/cards/UsersList2.astro b/shared/components/cards/UsersList2.astro index 17150bcb2..ed2d81dcc 100644 --- a/shared/components/cards/UsersList2.astro +++ b/shared/components/cards/UsersList2.astro @@ -3,6 +3,7 @@ import Avatar from '@ui/Avatar.astro' import CardTitle from '@ui/CardTitle.astro' import people from '@data/people.json' import { randomNumber, timeagoLabel } from '@shared/lib/pseudo-random' +import { requireIndex } from '@shared/lib/array' interface Person { full_name?: string @@ -19,12 +20,12 @@ interface Props { const { limit = 10, offset = 0, title = 'Top users', class: className } = Astro.props -const colors = 'green,red,yellow,x,x'.split(',') -const statusLabels: Record = { green: 'Online', red: 'Busy', yellow: 'Away', x: 'Offline' } +const colors = ['green', 'red', 'yellow', 'x', 'x'] as const +const statusLabels: Record<(typeof colors)[number], string> = { green: 'Online', red: 'Busy', yellow: 'Away', x: 'Offline' } const rows = (people as Person[]).slice(offset, offset + limit).map((person, idx) => { const index = idx + 1 // forloop.index (1-based) - const status = colors[randomNumber(index + 5, 0, colors.length - 1)] + const status = requireIndex(colors, randomNumber(index + 5, 0, colors.length - 1)) return { person, status: status !== 'x' ? status : 'secondary', diff --git a/shared/components/cards/music/TrackInfo.astro b/shared/components/cards/music/TrackInfo.astro index fc04acb4b..8f264b602 100644 --- a/shared/components/cards/music/TrackInfo.astro +++ b/shared/components/cards/music/TrackInfo.astro @@ -1,5 +1,6 @@ --- import tracks from '@data/tracks.json' +import { requireIndex } from '@shared/lib/array' interface Props { trackId?: number @@ -7,13 +8,14 @@ interface Props { const { trackId = 5 } = Astro.props -const track = tracks[trackId] +const track = requireIndex(tracks, trackId) +const trackImage = requireIndex(track.album.images, 1) ---
- {track.name} + {track.name}
diff --git a/shared/components/cards/music/TracksList.astro b/shared/components/cards/music/TracksList.astro index 6f7c16fda..3d3cf8c8e 100644 --- a/shared/components/cards/music/TracksList.astro +++ b/shared/components/cards/music/TracksList.astro @@ -6,6 +6,7 @@ import ListGroup from '@ui/ListGroup.astro' import ListGroupItem from '@ui/ListGroupItem.astro' import tracks from '@data/tracks.json' import { millisecondsToMinutes } from '@shared/lib/string-format' +import { requireIndex } from '@shared/lib/array' const items = tracks.slice(0, 12) --- @@ -18,7 +19,7 @@ const items = tracks.slice(0, 12)
{index + 1}
- {track.name} + {track.name}
{track.name} diff --git a/shared/components/layout/HeaderActionsButtons.astro b/shared/components/layout/HeaderActionsButtons.astro index ae28a820b..a0dae8194 100644 --- a/shared/components/layout/HeaderActionsButtons.astro +++ b/shared/components/layout/HeaderActionsButtons.astro @@ -8,7 +8,7 @@ import ReportModalContent from '../modals/ReportModalContent.astro' interface Props { /** layout-navbar-overlap && layout-navbar-dark → the "New view" button is color="dark" */ - dark?: boolean + dark?: boolean | undefined } const { dark } = Astro.props diff --git a/shared/components/layout/HeaderProfile.astro b/shared/components/layout/HeaderProfile.astro index 37e23ffbd..9a57df632 100644 --- a/shared/components/layout/HeaderProfile.astro +++ b/shared/components/layout/HeaderProfile.astro @@ -4,8 +4,9 @@ import Icon from '@ui/Icon.astro' import Button from '@ui/Button.astro' import ButtonList from '@ui/ButtonList.astro' import people from '@data/people.json' +import { requireIndex } from '@shared/lib/array' -const person = people[3] +const person = requireIndex(people, 3) --- diff --git a/shared/components/layout/PageHeader.astro b/shared/components/layout/PageHeader.astro index eb155e9be..0a216360a 100644 --- a/shared/components/layout/PageHeader.astro +++ b/shared/components/layout/PageHeader.astro @@ -15,21 +15,21 @@ import HeaderUptime from './HeaderUptime.astro'; interface Props { /** page-header — the page title; without it the whole block is not rendered */ - title?: string; + title?: string | undefined; /** page-header-pretitle */ - pretitle?: string; + pretitle?: string | undefined; /** page-header-description */ - description?: string; + description?: string | undefined; /** page-header-actions — name of an include from layout/header-actions/, e.g. "buttons" */ - actions?: string; + actions?: string | undefined; /** page-header-class */ class?: string; /** page-header-icon */ icon?: string; /** page-header-file — name of an include from layout/headers/, e.g. "profile" */ - file?: string; + file?: string | undefined; /** layout-navbar-overlap && layout-navbar-dark → text-white on .page-header */ - textWhite?: boolean; + textWhite?: boolean | undefined; } const { title, pretitle, description, actions, class: className, icon, file, textWhite } = Astro.props; diff --git a/shared/components/marketing/SectionDivider.astro b/shared/components/marketing/SectionDivider.astro index de32b9064..d27017521 100644 --- a/shared/components/marketing/SectionDivider.astro +++ b/shared/components/marketing/SectionDivider.astro @@ -1,7 +1,7 @@ --- // Renders nothing unless divider is 'waves' or 'arc'. interface Props { - divider?: string + divider?: string | undefined } const { divider } = Astro.props diff --git a/shared/components/modals/AddTaskModalContent.astro b/shared/components/modals/AddTaskModalContent.astro index dd91fbdb8..0bb31ecbc 100644 --- a/shared/components/modals/AddTaskModalContent.astro +++ b/shared/components/modals/AddTaskModalContent.astro @@ -2,13 +2,14 @@ // selected ids "5,6,2,3" → people[id-1]. import people from '@data/people.json' import FormGroup from '@ui/FormGroup.astro' +import { requireIndex } from '@shared/lib/array' interface Person { id: string full_name: string } -const selectedPeople = ['5', '6', '2', '3'].map((idStr) => (people as Person[])[Number(idStr) - 1]) +const selectedPeople = ['5', '6', '2', '3'].map((idStr) => requireIndex(people as Person[], Number(idStr) - 1)) ---