Problem/Motivation

Current AjaxCommand definition is redundant because command key is defined in the Drupal.definedAjaxCommands interface and this key is needed in ajaxCommand type too.

An AjaxCommand definition example:

declare global {
  namespace Drupal {
    interface definedAjaxCommands {
      // Need to write command key twice.
      testCommand: ajaxCommand<'testCommand', {arg1: string, arg2: boolean}>
    }
  }
}

Proposed resolution

Change ajaxCommand type like below.

Before:

export type ajaxCommand<K extends string, P, R = void> = (ajax: Ajax, response: {command: K} & P, status: number) => R;

After:

export type ajaxCommand<P, R = void> = (ajax: Ajax, response: {command: keyof Drupal.definedAjaxCommands} & P, status: number) => R;

The previous AjaxCommand definition example changes into below.

declare global {
  namespace Drupal {
    interface definedAjaxCommands {
      testCommand: ajaxCommand<{arg1: string, arg2: boolean}>
    }
  }
}

Remaining tasks

API changes

Yes.
If this change is committed, existing definition needs to change.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tom konda created an issue. See original summary.

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

As suggested in the issue, this patch makes the module compatible with endroid/qr-code library v6.1+ where
the implicit nullable parameter deprecation was fixed.

Changes:
- Updated `composer.json` to require `endroid/qr-code: ^6.1`
- Refactored `QRImageResponse.php` to use the new v6 API with named constructor arguments
- Updated imports to use the new class locations (e.g., `ErrorCorrectionLevel` enum, `RoundBlockSizeMode`
enum)
- Properly initialize `$logo` and `$label` to `null` before conditional blocks

tom konda’s picture

@nickolaj
Thank you for creating MR and it looks good.
But your comment seems to be mentioning another issue.
Is this intentional?

nickolaj’s picture

Yea, sorry!

  • nickolaj committed 0015892a on 0.1.x
    Issue #3568730: Implemented the proposed resolution exactly as des...
    
tom konda’s picture

Status: Needs review » Fixed

Fixed.
Thanks @nickolaj

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.