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

action params type fix #23

Merged
merged 7 commits into from
Feb 2, 2024
Merged

action params type fix #23

merged 7 commits into from
Feb 2, 2024

Conversation

ssanjay1
Copy link
Contributor

@ssanjay1 ssanjay1 commented Feb 1, 2024

No description provided.

@changelog-app
Copy link

changelog-app bot commented Feb 1, 2024

Generate changelog in packages/legacy-client/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

action params type fix

Check the box to generate changelog(s)

  • Generate changelog entry

@@ -45,21 +45,37 @@ export interface ValidLegacyActionParameterTypes {
export type ActionArgs<
O extends OntologyDefinition<any>,
A extends keyof O["actions"],
> =
& {
> = NonNullableKeys<O["actions"][A]["parameters"]> extends never ? {
Copy link
Contributor Author

@ssanjay1 ssanjay1 Feb 1, 2024

Choose a reason for hiding this comment

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

Basically, the problem was that our types as they stand allowed you to pass in arrays to action args (based on our tests atleast). It was because if NonNullableKeys or NullableKeys were never, the type would look something like {nullableKeys} & {}, and for some reason having that & {} just allowed users to put in anything. Attempted to fix that here, but there may be a cleaner solution for this

Copy link
Contributor

Choose a reason for hiding this comment

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

Specifically {[P in never]: any} accepts []

@@ -81,6 +80,10 @@ describe("Actions", () => {
]
>();

expectTypeOf<typeof actions.createTask>()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really sure if this is the best thing to do here. Using toBeCallableWith was the only way I could get the arrays to pass through when we had the incorrect types, unfortunately, you can't use .not to check that we don't regress this behavior, so I put in expect-error, which should flag an error if it actually is callable with the array.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this as good as we can get for now. Once you add bulk actions support this test is going to just get deleted I guess anyhow.

type Result,
ReturnEditsMode,
import { ActionExecutionMode, ReturnEditsMode } from "../..";
import type {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This happened automatically on save, not sure if this is what we want

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷 unless you want to propose changes to dprint's config its fine by me

Copy link
Contributor

@mfedderly mfedderly left a comment

Choose a reason for hiding this comment

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

🥳

type Result,
ReturnEditsMode,
import { ActionExecutionMode, ReturnEditsMode } from "../..";
import type {
Copy link
Contributor

Choose a reason for hiding this comment

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

🤷 unless you want to propose changes to dprint's config its fine by me

@@ -81,6 +80,10 @@ describe("Actions", () => {
]
>();

expectTypeOf<typeof actions.createTask>()
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this as good as we can get for now. Once you add bulk actions support this test is going to just get deleted I guess anyhow.

@mfedderly mfedderly closed this Feb 2, 2024
@mfedderly mfedderly reopened this Feb 2, 2024
@ssanjay1 ssanjay1 merged commit 0b9302d into main Feb 2, 2024
6 checks passed
@ssanjay1 ssanjay1 deleted the ssanjay/fixactionparam branch February 2, 2024 20:54
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