This repository was archived by the owner on Dec 17, 2024. It is now read-only.
Added backwards compatible type supporting for events to have multiple values#105
Draft
Sam-Lee-17 wants to merge 1 commit intoclockwork-dog:mainfrom
Draft
Added backwards compatible type supporting for events to have multiple values#105Sam-Lee-17 wants to merge 1 commit intoclockwork-dog:mainfrom
Sam-Lee-17 wants to merge 1 commit intoclockwork-dog:mainfrom
Conversation
chetbox
reviewed
Jun 6, 2024
Comment on lines
39
to
42
| export type PluginManifestEventJson = { | ||
| name: string; | ||
| value?: CogsValueType; | ||
| value?: CogsValueType | { name: string; value: CogsValueType }[]; | ||
| }; |
Collaborator
There was a problem hiding this comment.
How about?
/** @deprecated */
export type PluginManifestEventSingleParameterJson = {
name: string;
value?: CogsValueType;
};
export type PluginManifestEventMultiParameterJson = {
name: string;
value?: { name: string; value: CogsValueType }[];
};
export type PluginManifestEventJson = PluginManifestEventMultiParameterJson | PluginManifestEventSingleParameterJson;
chetbox
reviewed
Jun 6, 2024
Comment on lines
52
to
61
| export type EventFromCogsAsObject<Manifest extends CogsPluginManifest> = DistributeObject< | ||
| { | ||
| [Name in EventNameFromCogs<Manifest>]: TypeFromCogsValueType<Extract<DeepMutable<EventFromCogs<Manifest>>, { name: Name }>['value']>; | ||
| [Name in EventNameFromCogs<Manifest>]: | ||
| Extract<DeepMutable<EventFromCogs<Manifest>>, { name: Name }> extends { name: Name; value: infer V extends CogsValueType } ? TypeFromCogsValueType<V> : | ||
| Extract<DeepMutable<EventFromCogs<Manifest>>, { name: Name }> extends { name: Name; value: infer V extends { name: string; value: CogsValueType }[] } ? DistributeObject< | ||
| { | ||
| [ValueName in V[number]['name']]: TypeFromCogsValueType<V[number]['value']> | ||
| } | ||
| > : undefined; | ||
| } |
Collaborator
There was a problem hiding this comment.
How about separate utility types for the old and new version?
chetbox
reviewed
Jun 6, 2024
| public readonly name: CogsEvent['name'], | ||
| public readonly value: CogsEvent extends { name: string; value: CogsValueType } | ||
| ? ManifestTypes.TypeFromCogsValueType<CogsEvent['value']> | ||
| : CogsEvent extends { name: string; value: { name: string; value: CogsValueType }[] } |
Collaborator
There was a problem hiding this comment.
e.g. CogsEvent extends PluginManifestEventMultiParameterJson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.