feat: make Instance.create optional to fix type compatibility #64
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.
Summary
This PR fixes issue #43 by making the
createmethod optional on theInstancetype, which allows pool-returned instances to be properly typed asInstance.Problem
Previously, users couldn't type their code properly when using the Pool:
This error occurred because:
Poolinternally usedInstance_type (defined asOmit<Instance, 'create'>)start()returnedInstance_instead ofInstanceInstance_was not assignable toInstancedue to the missingcreatepropertySolution
Instead of using the internal
Instance_type, we:createoptional in theInstancetype definition (create?instead ofcreate)Instance_internal type from Pool.ts entirelyInstancetype directly for all its methodsPool.start()to ensure the instance has acreatemethod when creating new instancescreatemethod to returnInstance<_internal>instead ofOmit<Instance<_internal>, 'create'>After this change
The
Instancetype now properly represents both:createmethod)createmethod)Test plan
pnpm check:types)pnpm check)Fixes #43
🤖 Generated with Claude Code