Skip to content

Conversation

@jpsantosbh
Copy link
Collaborator

@jpsantosbh jpsantosbh commented Jul 14, 2025

Description

Makes Prettify type function to preserve the callable objects' types to fix:

Status_and_call_ts__Working_Tree___call_ts__—_puc-client

Type of change

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

Code snippets

In case of new feature or breaking changes, please include code snippets.

@changeset-bot
Copy link

changeset-bot bot commented Jul 14, 2025

🦋 Changeset detected

Latest commit: 24aae49

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@signalwire/core Patch
@signalwire/client Patch
@signalwire/js Patch
@signalwire/realtime-api Patch
@signalwire/web-api Patch
@signalwire/webrtc Patch
@sw-internal/e2e-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Prettify utility type so it preserves both plain functions and callable objects (functions with properties), and records that change in the project’s changelog.

  • Extend Prettify to detect and preserve callable object types
  • Add a patch entry in the .changeset for this fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/types/utils.ts Add a conditional branch in Prettify to preserve callable objects
.changeset/fancy-dancers-dig.md Add patch changelog entry for fixing Prettify
Comments suppressed due to low confidence (2)

packages/core/src/types/utils.ts:135

  • Update the doc comment to mention that Prettify now also preserves callable object types, e.g., change 'preserving function types' to 'preserving function and callable object types'.
 * Flattens object types for better IDE display while preserving function types

packages/core/src/types/utils.ts:139

  • Add unit tests to verify that Prettify correctly preserves callable object types (functions with properties), ensuring the new branch behaves as intended.
  : T extends { (...args: any[]): any } // Check for callable objects

Comment on lines +137 to +143
export type Prettify<T> = T extends { (...args: any[]): any }
? T // Preserve callable objects (functions with properties, overloads, etc.)
: T extends object
? {
[K in keyof T]: T[K]
} & {}
: T
Copy link
Contributor

Choose a reason for hiding this comment

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

Might we want to have type assertions to verify that this utility type is working as expected?

I did a little research, and here is a more comprehensive utility type Compute from ts-toolbelt lib
https://github.com/millsp/ts-toolbelt/blob/master/sources/Any/Compute.ts, which is well tested but maybe overkill for the use case here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Vitest can provide type testing. See https://vitest.dev/guide/testing-types.html

@LittorWired
Copy link
Contributor

Just pointing out that the e2e tests are failing

@jpsantosbh
Copy link
Collaborator Author

  • Tests / Browser Client SDK production / Run E2E tests (20.x, callfabric) (pull_request)

The only relevant is [Tests / Browser Client SDK production / Run E2E tests (20.x, callfabric) (pull_request)](https://github.com/signalwire/signalwire-js/actions/runs/16265435406/job/45920100905?pr=1257)

It's failing cause the conversations API is not working in prod ATM.

The other are just flaky errors.

Copy link
Contributor

@LittorWired LittorWired left a comment

Choose a reason for hiding this comment

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

Left some optional comments to address testing the Prettify<T> type util so it can be ensured it is working as expected.

@jpsantosbh jpsantosbh merged commit b916036 into main Jul 14, 2025
23 of 31 checks passed
@jpsantosbh jpsantosbh deleted the joao/fix_callable_object_types branch July 14, 2025 13:41
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.

3 participants