Skip to content

Conversation

@kazupon
Copy link
Member

@kazupon kazupon commented Nov 12, 2025

Description

Linked Issues

Additional context

Summary by CodeRabbit

  • Documentation

    • Reorganized README with clearer structure and new API documentation section.
    • Updated installation and usage examples for Deno, Bun, Browser, and Node environments.
  • Refactor

    • Enhanced type safety for locale mapping functions.
    • Cleaned up internal type checking directives.

@kazupon kazupon added the bug Includes new features label Nov 12, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Warning

Rate limit exceeded

@kazupon has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 729f5e6 and bd8831c.

📒 Files selected for processing (1)
  • src/index.ts (1 hunks)

Walkthrough

Improved type safety by introducing a generic type parameter T extends unknown[] to mapToLocaleFromLanguageTag function, enabling stricter argument typing. Removed TypeScript error suppressions (// @ts-expect-error``) from multiple getHeaderLocales implementations now that underlying typing is correct. Reorganized README documentation.

Changes

Cohort / File(s) Summary
Documentation Reorganization
deno/README.md
Removed "Using Edge Releases" sections and detailed utilities subsections; introduced "🤝 API" section linking to external API docs; updated installation/import commands for Deno (deno add jsr:@intlify/utils``), Bun (bun add), and Browser (ESM import from esm.sh)
Type Safety Improvements
deno/http.ts, src/http.ts
Updated mapToLocaleFromLanguageTag signature to use generic parameter T extends unknown[]; getter now accepts (...args: T) and rest parameters are typed as T, improving type safety while maintaining runtime behavior via Reflect.apply
Error Suppression Removal
deno/web.ts, src/h3.ts, src/hono.ts, src/node.ts, src/web.ts
Removed inline TypeScript error suppressions (// @ts-expect-error``) from getHeaderLocales implementations; functions now rely on corrected generic typing without explicit type-check bypasses
Module Documentation
deno/index.ts
Added header comment block documenting default module entry point and runtime-agnostic exports with import example

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Key areas requiring attention:
    • Verify that the generic type parameter T extends unknown[] in mapToLocaleFromLanguageTag correctly aligns callers' argument types across all implementations (deno/http.ts and src/http.ts)
    • Confirm that removing // @ts-expect-error`` suppressions from getHeaderLocales functions (h3.ts, hono.ts, node.ts, web.ts, deno/web.ts) does not surface new TypeScript errors; validate that the corrected generic typing satisfies type checking
    • Review README changes for completeness and clarity of the new API section link

Possibly related PRs

  • fix: wrong default options #65: Modifies the same locale/header helper files (src/http.ts, src/h3.ts, src/hono.ts, src/node.ts, src/web.ts); refactors caller signatures to use options objects alongside this PR's typing improvements

Suggested labels

improvement

Poem

🐰 Generic types now safely bind,
No more errors we suppress and hide,
Documentation, lean and refined,
Our rabbit warren grows with pride!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: type errors' is vague and generic, using a non-descriptive term that doesn't convey what specific type errors are being fixed or which components are affected. Make the title more specific by identifying the key type error being addressed, e.g., 'fix: improve type safety in mapToLocaleFromLanguageTag' or 'fix: remove type suppressions and improve typing'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 12, 2025

Open in StackBlitz

npm i https://pkg.pr.new/intlify/utils/@intlify/utils@66

commit: bd8831c

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a24b30 and 729f5e6.

📒 Files selected for processing (9)
  • deno/README.md (2 hunks)
  • deno/http.ts (2 hunks)
  • deno/index.ts (1 hunks)
  • deno/web.ts (0 hunks)
  • src/h3.ts (0 hunks)
  • src/hono.ts (0 hunks)
  • src/http.ts (2 hunks)
  • src/node.ts (0 hunks)
  • src/web.ts (0 hunks)
💤 Files with no reviewable changes (5)
  • src/node.ts
  • deno/web.ts
  • src/hono.ts
  • src/web.ts
  • src/h3.ts
🔇 Additional comments (7)
deno/http.ts (2)

19-19: LGTM!

The author attribution in the comment improves clarity.


222-224: Excellent type safety improvement!

The generic type parameter T extends unknown[] ensures that the arguments passed to mapToLocaleFromLanguageTag match the parameter types expected by the getter function, preventing type mismatches at compile time while preserving runtime behavior.

src/http.ts (2)

19-19: LGTM!

Author attribution improves comment clarity, consistent with the change in deno/http.ts.


222-224: LGTM!

The generic type parameter addition mirrors the improvement in deno/http.ts, ensuring consistent type safety across both the src and deno implementations.

deno/README.md (3)

37-39: LGTM!

Using deno add jsr:@intlify/utils aligns with modern Deno dependency management practices.


44-44: LGTM!

The bun add command is the standard way to add dependencies in Bun, consistent with other package managers.


77-79: LGTM!

Simplifying the README to point to API documentation reduces duplication and establishes a single source of truth for API details.

Comment on lines +1 to +12
/**
* `@intlify/utils` default module entry.
*
* `@inlityf/utils` will export javascript runtime agnostic utility functions and types.
*
* @example
* ```ts
* import { parseAcceptLanguage, isLocale, getHeaderLocale } from '@intlify/utils'
* ```
*
* @module default
*/
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in module name.

Line 4 contains a typo: @inlityf/utils should be @intlify/utils.

Apply this diff:

-/**
- * `@intlify/utils` default module entry.
- *
- * `@inlityf/utils` will export javascript runtime agnostic utility functions and types.
- *
- * @example
- * ```ts
- * import { parseAcceptLanguage, isLocale, getHeaderLocale } from '@intlify/utils'
- * ```
- *
- * @module default
- */
+/**
+ * `@intlify/utils` default module entry.
+ *
+ * `@intlify/utils` will export javascript runtime agnostic utility functions and types.
+ *
+ * @example
+ * ```ts
+ * import { parseAcceptLanguage, isLocale, getHeaderLocale } from '@intlify/utils'
+ * ```
+ *
+ * @module default
+ */
🤖 Prompt for AI Agents
In deno/index.ts around lines 1 to 12, there's a typo in the module description:
replace the incorrect `@inlityf/utils` with the correct `@intlify/utils`
everywhere in the block comment (including the example and description) so the
module name is consistent and accurate; update the comment text accordingly and
ensure no other spelling mistakes remain in that header block.

@kazupon kazupon merged commit 81c8f1f into main Nov 12, 2025
9 checks passed
@kazupon kazupon deleted the fix/type-error branch November 12, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Includes new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants