Skip to content

Adding types in Personalize.js and Parseinstructions.js - #2

Open
akanshaa-18 wants to merge 1 commit into
adobecom:mainfrom
akanshaa-18:main
Open

Adding types in Personalize.js and Parseinstructions.js#2
akanshaa-18 wants to merge 1 commit into
adobecom:mainfrom
akanshaa-18:main

Conversation

@akanshaa-18

Copy link
Copy Markdown

Filled the 'unknown' types with actual types.
Resolves: MWPW-175569

@sharmrj sharmrj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd prefer if an Instruction encoded a single instruction.
Also we should use tagged unions.

type Instruction = InstructionType1 | InstructionType2 | ...;
type InstructionType1 = {
  type: "InstructionType1";
  selector: string;
  ...
}

// This way we can do the following in the future:

const handleInstruction = (instruction: Instruction): void => { // for example
  switch (instruction.type) {
   // ts error if the type is not in the tagged union
    case "InstructionType1": f();
      break;
    case "InstructionType2":  g();
      break;
    default: {
      // we get a type error if we aren't handling every case
      const exhaustivenessCheck: never = ""
    }
  }
};

Comment on lines +4 to +9
requestId: string;
handle: Array<{
payload: any[];
type: string;
[key: string]: any;
}>;

@sharmrj sharmrj Jun 26, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Avoid using any. We want to explicitly write out the type of handle because if we don't have something, or have something extra, we get a typeerror at compile time. Using any defeats the purpose of using typescript.

@adobecom-git-stale-pr-bot adobecom-git-stale-pr-bot Bot added the stale No recent activity label Sep 3, 2026
@adobecom-git-stale-pr-bot

Copy link
Copy Markdown

No activity in 7 days. Will be labeled stale at 14 days. Auto-close is disabled this run. Add stale-ignore to exempt.

No activity in 14 days, labeled stale (removed automatically on new activity). Auto-close is disabled this run. Add stale-ignore to exempt.

No activity in 21 days, labeled autoclose-pending (removed automatically on new activity). Would normally close in 7 days, but auto-close is disabled this run. Add autoclose-ignore to exempt.

No activity in 28 days. Would normally close now, but auto-close is disabled this run. Add autoclose-ignore to exempt.


Rundeck job Git Stale PR Check (git-stale-pr-bot), execution 2739336, project global, run by casalino

@adobecom-git-stale-pr-bot adobecom-git-stale-pr-bot Bot added the autoclose-pending Will be auto-closed soon label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoclose-pending Will be auto-closed soon stale No recent activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants