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: implement type safety fallback #2933

Merged
merged 1 commit into from
Nov 15, 2024
Merged
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
7 changes: 5 additions & 2 deletions packages/website/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,12 @@ export const getStaticPaths: GetStaticPaths = async () => {
?.sectionCollection?.items[0];
}

const sectionSlug = section?.slug ?? 'default-section';
const itemSlug = item?.slug ?? 'default-item';
Comment on lines +298 to +299
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these exist?

Copy link
Collaborator Author

@Lelith Lelith Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they usually are never undefined, but the type script error is now blocking the build, so i implemented a quick fallback to avoid the error.
the issue is that neither item nor section are properly typed and so this is the point where it falls trough. i can also go ahead and do a wider refactoring, fixing the initial types. but as all builds are failing at the moment, i wanted to have a quick fix.

Copy link
Collaborator

@denkristoffer denkristoffer Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean do these default sections and items exist or would something break if they actually got used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, no, just the slug name and item would be displayed like that.

const slug = item.authProtected
? [section.slug, 'protected', item.slug]
: [section.slug, item.slug];
? [sectionSlug, 'protected', itemSlug]
: [sectionSlug, itemSlug];

return {
params: {
slug,
Expand Down
Loading