Skip to content

fix: correct resource type ordering and type handling in sync script - #10212

Open
oscarbol09 wants to merge 2 commits into
nilbuild:masterfrom
oscarbol09:fix/sync-script-type-and-ordering
Open

fix: correct resource type ordering and type handling in sync script#10212
oscarbol09 wants to merge 2 commits into
nilbuild:masterfrom
oscarbol09:fix/sync-script-type-and-ordering

Conversation

@oscarbol09

Copy link
Copy Markdown

What

Fixes two issues in scripts/sync-repo-to-database.ts and wires up type checking so they cannot regress:

  1. Resource type ordering bug — the sort() only knew about official, opensource, article, video and feed. Resources of type course, podcast, book and roadmap got indexOf -1 and were therefore sorted before everything else, breaking the order documented in contributing.md. The sort order is now derived from allowedOfficialRoadmapTopicResourceType, the single source of truth.

  2. Suppressed type error (TODO) — the @ts-expect-error - TODO: fix this at line 177 was masking a real TS2740: HTMLElement resolved to the DOM lib type while querySelectorAll('ul') returns node-html-parser's HTMLElement (274+ properties missing). Fixed by importing the type from node-html-parser; the directive is removed. Also removed an as any cast in the same block.

  3. No typecheck script existed — the sync tooling was never typechecked (tsx skips it), which is why the suppressed error went unnoticed. Added npm run typecheck (tsc --noEmit).

Verification

  • npx tsc --noEmit passes cleanly with the directive removed.
  • Functional check with the real parsing pipeline (node-html-parser + markdown-it): before, course, book, podcast, roadmap links landed first; after, output follows the canonical order roadmap, official, opensource, article, course, podcast, video, book, feed.
  • prettier --check passes.

The sort only knew about official/opensource/article/video/feed, so course, podcast, book and roadmap resources got indexOf -1 and were placed before everything else. Derive the sort order from the allowed resource types list instead.

Also imports HTMLElement from node-html-parser to fix the suppressed TS2740 error (the @ts-expect-error workaround is no longer needed) and drops the 'as any' cast.
tsc --noEmit was never wired into the repo, which is how the suppressed type error went unnoticed. Add a script so the sync tooling can be typechecked.
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.

1 participant