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.
Comments
Comment #4
nickolajAs 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
Comment #5
tom konda@nickolaj
Thank you for creating MR and it looks good.
But your comment seems to be mentioning another issue.
Is this intentional?
Comment #6
nickolajYea, sorry!
Comment #8
tom kondaFixed.
Thanks @nickolaj