Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marks Select arrays as readonly #6999

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Conversation

cybae0804
Copy link
Contributor

Fixes #4976

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Previous attempt + reversion #5171

Select components don't actually mutate the arrays provided, but because it is not marked as readonly, the consumers sometimes have to cast the prop to not be readonly. This fixes the issue by marking the props correctly as readonly.

Reviewers should focus on:

Screenshot

@changelog-app
Copy link

changelog-app bot commented Sep 24, 2024

Generate changelog in packages/select/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Marks Select arrays as readonly

Check the box to generate changelog(s)

  • Generate changelog entry

bvandercar-vt
bvandercar-vt previously approved these changes Sep 24, 2024
@policy-bot policy-bot bot dismissed bvandercar-vt’s stale review October 9, 2024 20:43

Invalidated by push of 933c1e2

@svc-palantir-github
Copy link

compilefix

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

compile

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Copy link
Member

@invliD invliD left a comment

Choose a reason for hiding this comment

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

I don't like that this change forces consumers to deal with readonly arrays. Most code I have seen does not bother declaring arrays readonly, so returning readonly arrays in callbacks would break many such usages.

We're experimenting with a version that uses generics to return the same kind of array you pass in (readonly or not), and if that works out we will go with that approach instead. Otherwise, we'll come back to this.

@ggdouglas ggdouglas mentioned this pull request Oct 30, 2024
2 tasks
@ggdouglas
Copy link
Contributor

@cybae0804 @invliD Here's an implementation that leverages generics as described: #6999

This accomplishes the same goal, while also having the advantage of being backwards compatible. This will hopefully make it much easier to transition existing code to use readonly arrays.

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.

Select's types don't accept readonly item arrays
5 participants