Skip to content

Conversation

Jerboas86
Copy link
Contributor

@Jerboas86 Jerboas86 commented Jun 4, 2025

Fix #175

I modify just the minimum required code to make the compiler happy.

add the following properties to tsconfig.build.json

"exactOptionalPropertyTypes": true,
"noImplicitOverride": true,
"verbatimModuleSyntax": true,

Summary by CodeRabbit

  • Refactor

    • Improved TypeScript type definitions for optional properties to explicitly allow undefined values.
    • Updated import statements to use type-only imports for clearer type usage and improved code clarity.
    • Added the override keyword to class properties where applicable.
  • Chores

    • Enhanced TypeScript configuration for stricter type checking and improved code safety.

Copy link

coderabbitai bot commented Jun 4, 2025

Walkthrough

The changes update TypeScript configuration and codebase to support stricter type checking by enabling exactOptionalPropertyTypes, noImplicitOverride, and verbatimModuleSyntax. Corresponding code adjustments include explicit type annotations for optional properties, use of type-only imports, and marking class property overrides, without altering runtime logic or exported APIs.

Changes

File(s) Change Summary
tsconfig.build.json Added exactOptionalPropertyTypes, noImplicitOverride, and verbatimModuleSyntax to TypeScript config.
src/glue/messages.ts Explicitly annotated optional interface properties with `
src/model-manager.ts Updated optional interface properties to explicitly include `
src/worker.ts Changed interface optional property to `
src/cache-manager.ts, src/glue/glue.ts, Changed imports to type-only imports using import type.
src/wllama.ts Used type-only imports; added override keyword for class property.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TypeScript Compiler
    participant SourceCode

    User->>TypeScript Compiler: Build project
    TypeScript Compiler->>SourceCode: Parse with strict options (exactOptionalPropertyTypes, etc.)
    SourceCode-->>TypeScript Compiler: Provide explicit types, type-only imports, overrides
    TypeScript Compiler-->>User: Emit JavaScript (stricter type checks enforced)
Loading

Assessment against linked issues

Objective Addressed Explanation
Update tsconfig to use stricter options: exactOptionalPropertyTypes, noImplicitOverride, verbatimModuleSyntax (#175)
Update codebase to comply with stricter TypeScript type checks (#175)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

In the warren of TypeScript, strict and bright,
We bunnies checked our types with delight!
Optional fields now clear and defined,
Overrides explicit, no errors to find.
With configs in place, the build hops along—
In the land of strict typing, we all belong! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4bd5e7 and 5b053eb.

📒 Files selected for processing (7)
  • src/cache-manager.ts (1 hunks)
  • src/glue/glue.ts (1 hunks)
  • src/glue/messages.ts (2 hunks)
  • src/model-manager.ts (2 hunks)
  • src/wllama.ts (2 hunks)
  • src/worker.ts (2 hunks)
  • tsconfig.build.json (1 hunks)
🔇 Additional comments (11)
tsconfig.build.json (1)

21-23: LGTM! Excellent TypeScript strict configuration.

These three compiler options significantly enhance type safety:

  • exactOptionalPropertyTypes: Ensures optional properties explicitly allow undefined
  • noImplicitOverride: Requires explicit override keyword for class method overrides
  • verbatimModuleSyntax: Enforces type-only imports for types, improving build output
src/glue/messages.ts (2)

1000-1002: Type changes are correct for exactOptionalPropertyTypes.

The explicit addition of | undefined to optional properties is syntactically correct and required by the exactOptionalPropertyTypes compiler option. However, ensure the generator script produces these changes to prevent them from being overwritten.

Also applies to: 1006-1012, 1014-1014


1319-1319: Consistent optional property type handling.

The tmpl property correctly includes | undefined to satisfy the exactOptionalPropertyTypes requirement.

src/glue/glue.ts (1)

1-5: Correct type-only import implementation.

The conversion of GlueMsg to a type-only import is appropriate since it's used exclusively for type annotations. The runtime imports (GLUE_MESSAGE_PROTOTYPES, GLUE_VERSION) correctly remain as regular imports.

src/cache-manager.ts (1)

1-1: Appropriate type-only import conversion.

Converting DownloadProgressCallback to a type-only import is correct since it's used exclusively for type annotations (DownloadOptions interface and callback parameter typing).

src/worker.ts (2)

15-15: LGTM: Correct implementation of type-only import.

The change from runtime import to type-only import aligns with the verbatimModuleSyntax TypeScript compiler option and is appropriate since GlueMsg is only used for type annotations.


47-47: LGTM: Correct implementation of explicit undefined typing.

The change from buffers?: ArrayBuffer[] to buffers?: ArrayBuffer[] | undefined aligns with the exactOptionalPropertyTypes TypeScript compiler option, making the undefined possibility explicit.

src/wllama.ts (2)

12-12: LGTM: Correct implementation of type-only imports.

The changes to use import type for DownloadOptions and the message interfaces align with the verbatimModuleSyntax TypeScript compiler option. These imports are used exclusively for type annotations and don't require runtime imports.

Also applies to: 14-32


263-263: LGTM: Correct implementation of explicit override annotation.

The addition of the override keyword is appropriate since WllamaAbortError extends Error and overrides the name property. This aligns with the noImplicitOverride TypeScript compiler option.

src/model-manager.ts (2)

1-6: LGTM: Correct implementation of type-only imports.

The changes to use import type for CacheEntry, DownloadOptions, and WllamaLogger align with the verbatimModuleSyntax TypeScript compiler option. These imports are used exclusively for type annotations.


44-44: LGTM: Correct implementation of explicit undefined typing.

The changes from parallelDownloads?: number to parallelDownloads?: number | undefined and allowOffline?: boolean to allowOffline?: boolean | undefined align with the exactOptionalPropertyTypes TypeScript compiler option, making the undefined possibility explicit for optional properties.

Also applies to: 50-50

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Owner

@ngxson ngxson left a comment

Choose a reason for hiding this comment

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

sorry for the delay. this looks good, thanks

merging when the CI passes

@ngxson ngxson merged commit fc41184 into ngxson:master Jun 7, 2025
2 checks passed
@Jerboas86
Copy link
Contributor Author

Could you make a release for this PR plz ?

@ngxson ngxson mentioned this pull request Jul 14, 2025
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.

wllama requires laxed tsconfig.json
2 participants