Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 20, 2026

Addresses review feedback on #105 regarding the @ts-ignore comment in the rating middleware. The regex validates vote is either "up" or "down", but TypeScript infers string from the regex match, requiring type assertion for createRating().

Changes

  • Replaced @ts-ignore with explicit type guard checking for 'up' or 'down'
  • TypeScript now narrows the type through control flow analysis
  • Added defensive 400 error for invalid vote values (unreachable due to regex, but satisfies type checker)

Example

Before:

let vote = match[2];
// @ts-ignore (Type-safety is enforced by regex)
await directus.createRating(vote, podcast);

After:

let voteString = match[2];
if (voteString !== 'up' && voteString !== 'down') {
  throw createError({ statusCode: 400, message: 'Invalid vote value' });
}
const vote = voteString;  // TypeScript infers "up" | "down"
await directus.createRating(vote, podcast);

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 20, 2026 14:16
Co-authored-by: Jan0707 <1663330+Jan0707@users.noreply.github.com>
Co-authored-by: Jan0707 <1663330+Jan0707@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
programmierbar-website Ready Ready Preview, Comment Jan 20, 2026 2:22pm

Request Review

Copilot AI changed the title [WIP] Update podcast ratings implementation based on feedback Replace type suppression with proper type narrowing in rating middleware Jan 20, 2026
Copilot AI requested a review from Jan0707 January 20, 2026 14:20
@Jan0707 Jan0707 marked this pull request as ready for review January 20, 2026 15:08
@Jan0707 Jan0707 merged commit ecda5c4 into ratings Jan 20, 2026
1 of 2 checks passed
@Jan0707 Jan0707 deleted the copilot/sub-pr-105-another-one branch January 20, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants