fix(types): make applyGetPermalinks TypeScript 6 strict-safe - #708
Merged
prototypa merged 1 commit intoJun 4, 2026
Merged
Conversation
Under TypeScript 6.0, strict (and noImplicitAny) is on by default, which
surfaced 19 implicit-any errors in applyGetPermalinks (ts7053/7023/7024):
indexing a bare object/{} and an un-annotated recursive return type.
Type menu as unknown with an explicit return type, iterate with
Object.entries instead of for...in bracket indexing, and use a
Record<string, unknown> accumulator. Behavior is unchanged.
Fixes arthelokyo#707
This was referenced Jun 4, 2026
prototypa
approved these changes
Jun 4, 2026
Contributor
|
Thanks @danfitz36 |
prototypa
pushed a commit
that referenced
this pull request
Jun 4, 2026
Same TS 6 strict-by-default issue as #708, in src/utils/blog.ts: getStaticPathsBlogCategory and getStaticPathsBlogTag build untyped {} accumulators and index them by string, producing 4 implicit-any errors (ts7053) under noImplicitAny. Type both accumulators as Record<string, Taxonomy> (the existing type for Post.category / Post.tags[]) and drop the now-redundant optional chaining on the narrowed index keys. Behavior is unchanged. Related to #707.
prototypa
added a commit
that referenced
this pull request
Aug 4, 2026
…licit-any fix(types): make applyGetPermalinks TypeScript 6 strict-safe
prototypa
pushed a commit
that referenced
this pull request
Aug 4, 2026
Same TS 6 strict-by-default issue as #708, in src/utils/blog.ts: getStaticPathsBlogCategory and getStaticPathsBlogTag build untyped {} accumulators and index them by string, producing 4 implicit-any errors (ts7053) under noImplicitAny. Type both accumulators as Record<string, Taxonomy> (the existing type for Post.category / Post.tags[]) and drop the now-redundant optional chaining on the narrowed index keys. Behavior is unchanged. Related to #707.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
applyGetPermalinks(src/utils/permalinks.ts) compile cleanly under TypeScript 6.0, wherestrict/noImplicitAnyis on by default.Fixes #707.
Why
The function took
menu: object = {}, iterated withfor...in, and read/wrote via bracket indexing (menu[key],obj[key]) with no return-type annotation. WithnoImplicitAnyenabled, that produced 19 errors (17×ts7053, 1×ts7023, 1×ts7024) — indexing a bareobject/{}and an un-annotated recursive return type.Change
menu: unknownwith an explicit: unknownreturn type (breaks the recursive implicit-anyinference)Object.entries(menu)instead offor...in+ bracket indexing (no indexing of a non-indexable type)Record<string, unknown>accumulator instead ofconst obj = {}MenuHreftype to narrow thehrefobject branchRuntime behavior is unchanged — it's a pure typing fix.
Verification
With
typescript@6installed,npx astro checkno longer reports any errors inpermalinks.ts(was 19, now 0).eslintandprettierpass on the changed file.Note (out of scope)
While verifying,
astro checkunder TS 6 also surfaced the same{}-indexing pattern insrc/utils/blog.ts(4×ts7053) and an unrelatedts(2882)for a@fontsource-variable/*side-effect import inCustomStyles.astro. Those are left out of this PR to keep it focused on #707, but they're part of the same TS 6 readiness effort — happy to follow up with a PR forblog.tsif you'd like.