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

type WidgetExampleAttribute #1066

Merged
merged 2 commits into from
Nov 2, 2023
Merged

type WidgetExampleAttribute #1066

merged 2 commits into from
Nov 2, 2023

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Oct 30, 2023

Follow up to #1023

This PR renames some typing to be more clear. Check out the files tab

Copy link
Contributor

@SBrandeis SBrandeis left a comment

Choose a reason for hiding this comment

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

Better 👌

@@ -32,7 +31,7 @@
export let outputJson: string;
export let applyInputSample: (sample: TWidgetExample, opts?: ExampleRunOpts) => void = () => {};
export let validateExample: (sample: WidgetExample) => sample is TWidgetExample;
export let exampleQueryParams: QueryParam[] = [];
export let exampleQueryParams: WidgetExampleAttribute[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be even better if the type was tied to the concrete TWidgetExample

@@ -108,3 +108,7 @@ export type WidgetExample<TOutput = WidgetExampleOutput> =
| WidgetExampleTableDataInput<TOutput>
| WidgetExampleZeroShotTextInput<TOutput>
| WidgetExampleSentenceSimilarityInput<TOutput>;

type KeysOfUnion<T> = T extends any ? keyof T : never;
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this just keyof T?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they are different. In keyof T case, ts errs

@mishig25
Copy link
Collaborator Author

mishig25 commented Nov 2, 2023

merging it now. Might make the typing even stronger in subseq PR

@mishig25 mishig25 merged commit 4e8ec2b into main Nov 2, 2023
2 checks passed
@mishig25 mishig25 deleted the more_typing branch November 2, 2023 13:16
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