⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@konard
Copy link

@konard konard commented Dec 25, 2025

Summary

This PR fixes issue #43 by making the create method optional on the Instance type, which allows pool-returned instances to be properly typed as Instance.

Problem

Previously, users couldn't type their code properly when using the Pool:

import { definePool, Pool, Instance } from 'prool';

let instance: Instance;
instance = await pool.start(1);  // ❌ Type error!

This error occurred because:

  • The Pool internally used Instance_ type (defined as Omit<Instance, 'create'>)
  • Pool methods like start() returned Instance_ instead of Instance
  • Instance_ was not assignable to Instance due to the missing create property

Solution

Instead of using the internal Instance_ type, we:

  1. Made create optional in the Instance type definition (create? instead of create)
  2. Removed the Instance_ internal type from Pool.ts entirely
  3. Updated Pool to use Instance type directly for all its methods
  4. Added runtime check in Pool.start() to ensure the instance has a create method when creating new instances
  5. Updated return type of create method to return Instance<_internal> instead of Omit<Instance<_internal>, 'create'>

After this change

import { definePool, Pool, Instance } from 'prool';

let instance: Instance;
instance = await pool.start(1);  // ✅ Works!

The Instance type now properly represents both:

  • Direct instances (which have the create method)
  • Pool-returned instances (which don't have the create method)

Test plan

  • TypeScript type checking passes (pnpm check:types)
  • Linting passes (pnpm check)
  • Manual verification that the type error from issue Remove Instance_ internal type #43 is resolved

Fixes #43

🤖 Generated with Claude Code

konard and others added 2 commits December 25, 2025 11:19
Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: wevm#43
This change addresses issue wevm#43 by making the `create` method optional on
the Instance type. Previously, the Pool used an internal `Instance_` type
(defined as `Omit<Instance, 'create'>`) which was incompatible with the
public `Instance` type, causing type errors when users tried to type
pool-returned instances as `Instance`.

Changes:
- Make `create` property optional in Instance type (`create?` instead of `create`)
- Remove the internal `Instance_` type alias from Pool.ts
- Update Pool to use `Instance` type directly
- Add runtime check for create method in Pool.start()
- Update create method return type to return full Instance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Remove Instance_ internal type feat: make Instance.create optional to fix type compatibility Dec 25, 2025
@konard konard marked this pull request as ready for review December 25, 2025 10:26
@konard
Copy link
Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $3.034583 USD
  • Calculated by Anthropic: $2.047532 USD
  • Difference: $-0.987051 (-32.53%)
    📎 Log file uploaded as GitHub Gist (628KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Author

konard commented Dec 25, 2025

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

?? test-output.log

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

@konard
Copy link
Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.586610 USD
  • Calculated by Anthropic: $0.935182 USD
  • Difference: $-0.651428 (-41.06%)
    📎 Log file uploaded as GitHub Gist (861KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Remove Instance_ internal type

1 participant