fix(player-mock): Give PlayerMockService its own type so callers do not need a cast - #819
Open
Quenty wants to merge 1 commit into
Open
fix(player-mock): Give PlayerMockService its own type so callers do not need a cast#819Quenty wants to merge 1 commit into
Quenty wants to merge 1 commit into
Conversation
…ot need a cast CreatePlayer annotated its self parameter as PlayerMockServiceBase while the module table PlayerMockService itself carries no instance fields, so every call site had to launder the service through any to typecheck. Declare the module table as its own exported type intersected with the base, which keeps the inherited base methods resolving and lets serviceBag:GetService(PlayerMockService):CreatePlayer() typecheck directly. Types only, no runtime change.
Deploy Results
1 package deployed, 1 passed, 0 failed in 3.4s · View logs Test Results
52 packages tested, 52 passed, 0 failed in 2m45s |
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.
PlayerMockService annotated CreatePlayer's self parameter as PlayerMockServiceBase, but the module table it is called on carries no instance fields of its own, so serviceBag:GetService(PlayerMockService):CreatePlayer() never typechecked and every call site in this repo and in consuming repos had to launder the service through
anyfirst. Declaring the module table as its own exported type, intersected with the base so the inherited methods still resolve, makes those calls typecheck directly without a cast.This is types only and changes nothing at runtime. The same latent issue exists on PlayerMockServiceClient, but fixing it there means reshaping its Init override to keep the base signature, so I left it for a follow-up.