Skip to content

chore: updated deprecation notices and fixed types#386

Merged
chaitanyapotti merged 3 commits intomasterfrom
fix/types-generics-deprecation-notices
Mar 4, 2026
Merged

chore: updated deprecation notices and fixed types#386
chaitanyapotti merged 3 commits intomasterfrom
fix/types-generics-deprecation-notices

Conversation

@lwin-kyaw
Copy link
Contributor

@lwin-kyaw lwin-kyaw commented Mar 3, 2026

Motivation and Context

Jira Link:

Description

fix: Remove deprecation notices and fix type compatibility in JRPC types

Summary

  • Removed premature @deprecated annotations from V1 API types, classes, and functions that are still actively used across the codebase (BasePostMessageStream, PostMessageStream, isValidStreamMessage, SerializableError, Payload, ExtendedJsonRpcRequest).
  • Relocated ProviderEvents and SafeEventEmitterProvider from jrpcEngine.ts to safeEventEmitter.ts to co-locate them with the base class they extend and removed their deprecation notices.
  • Fixed type compatibility error in MiddlewareScaffold — scaffold handlers with narrowed request params (e.g. JRPCRequest<{ foo: string }>) were not assignable to the previous generic type. The fix removes the Context generic from MiddlewareScaffold, drops the intermediate ScaffoldMiddlewareHandler type, and uses a never-parameter function signature so that any handler with arbitrarily-narrowed params remains assignable.
  • Relaxed JRPCRequest<Params> generic from Params extends JRPCParams to Params = JRPCParams to allow non-JRPCParams types (e.g. { foo: string }) as request parameters.
  • Fixed frozen object mutation in PostMessageStream._postMessage — the data object is now shallow-copied before mutation to avoid errors when the incoming object is frozen.

Changed Files

File Change
src/jrpc/basePostMessageStream.ts Removed @deprecated from isValidStreamMessage and BasePostMessageStream
src/jrpc/interfaces.ts Removed @deprecated from Payload and ExtendedJsonRpcRequest; relaxed JRPCRequest generic constraint
src/jrpc/jrpcEngine.ts Moved ProviderEvents and SafeEventEmitterProvider out; updated imports
src/jrpc/safeEventEmitter.ts Added ProviderEvents type and SafeEventEmitterProvider interface
src/jrpc/index.ts Re-exported ProviderEvents and SafeEventEmitterProvider from new location
src/jrpc/serializableError.ts Removed @deprecated from SerializableError
src/jrpc/postMessageStream.ts Removed @deprecated from PostMessageStream; shallow-copy data before mutation
src/jrpc/v2/v2interfaces.ts Removed ScaffoldMiddlewareHandler; simplified MiddlewareScaffold type
src/jrpc/v2/createScaffoldMiddleware.ts Removed Context generic from MiddlewareScaffold usage; added type cast for handler
src/jrpc/v2/providerUtils.ts Updated imports to use safeEventEmitter instead of jrpcEngine
test/v2/createScaffoldMiddleware.test.ts Added test for scaffold handler with narrowed request params

Test Plan

  • Existing scaffold middleware tests pass
  • New test case validates that a handler with narrowed params (JRPCRequest<{ foo: string }>) works correctly at runtime
  • Verify no downstream type errors in consuming packages

How has this been tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code requires a db migration.

Note

Medium Risk
Mostly type- and export-level changes, but they affect public JRPC provider/scaffold typing and add a runtime tweak to PostMessageStream message handling that could impact cross-window messaging behavior.

Overview
Removes several premature @deprecated annotations from still-used JRPC V1 APIs (stream utilities, request types, and SerializableError).

Moves ProviderEvents and SafeEventEmitterProvider type definitions into safeEventEmitter.ts and updates exports/imports so both V1 and V2 provider utilities reference the shared definitions.

Fixes V2 scaffold typing by simplifying MiddlewareScaffold (dropping the context generic and using a never-arg function signature) and updating createScaffoldMiddleware accordingly; adds a test ensuring handlers with narrowed JRPCRequest params type-check and run.

Hardens PostMessageStream._postMessage by shallow-copying object payloads before mutating _origin, avoiding crashes when the input object is frozen.

Written by Cursor Bugbot for commit b4388a7. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@chaitanyapotti chaitanyapotti merged commit 4b2d491 into master Mar 4, 2026
5 checks passed
@chaitanyapotti chaitanyapotti deleted the fix/types-generics-deprecation-notices branch March 4, 2026 05:03
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.

2 participants