@aidc-toolkit/gs1 0.9.10-beta → 0.9.11-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/idkey.ts CHANGED
@@ -142,7 +142,7 @@ export interface IdentificationKeyValidation extends StringValidation {
142
142
  * Identification key validator. Validates an identification key against its definition in section 3 of the {@link
143
143
  * https://www.gs1.org/genspecs | GS1 General Specifications}.
144
144
  */
145
- export interface IdentificationKeyValidator<V extends IdentificationKeyValidation = IdentificationKeyValidation> extends StringValidator<V> {
145
+ export interface IdentificationKeyValidator<TIdentificationKeyValidation extends IdentificationKeyValidation = IdentificationKeyValidation> extends StringValidator<TIdentificationKeyValidation> {
146
146
  /**
147
147
  * Get the identification key type. Per the GS1 General Specifications, the identification key type determines
148
148
  * the remaining properties.
@@ -180,13 +180,13 @@ export interface IdentificationKeyValidator<V extends IdentificationKeyValidatio
180
180
  * @param validation
181
181
  * Identification key validation parameters.
182
182
  */
183
- validate: (identificationKey: string, validation?: V) => void;
183
+ validate: (identificationKey: string, validation?: TIdentificationKeyValidation) => void;
184
184
  }
185
185
 
186
186
  /**
187
187
  * Abstract identification key validator. Implements common functionality for an identification key validator.
188
188
  */
189
- abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyValidation = IdentificationKeyValidation> implements IdentificationKeyValidator<V> {
189
+ abstract class AbstractIdentificationKeyValidator<TIdentificationKeyValidation extends IdentificationKeyValidation = IdentificationKeyValidation> implements IdentificationKeyValidator<TIdentificationKeyValidation> {
190
190
  private static readonly CHARACTER_SET_CREATORS = [
191
191
  NUMERIC_CREATOR, AI82_CREATOR, AI39_CREATOR
192
192
  ];
@@ -319,7 +319,7 @@ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyVal
319
319
  PrefixManager.validatePrefix(this.prefixType, true, false, partialIdentificationKey, true, this.referenceCharacterSet === ContentCharacterSet.Numeric, positionOffset);
320
320
  }
321
321
 
322
- abstract validate(identificationKey: string, validation?: V): void;
322
+ abstract validate(identificationKey: string, validation?: TIdentificationKeyValidation): void;
323
323
  }
324
324
 
325
325
  /**
@@ -472,7 +472,16 @@ export enum GTINLevel {
472
472
  */
473
473
  export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
474
474
  /**
475
- * Zero-suppressed GTIN-12 validation parameters.
475
+ * Validation parameters for optional indicator digit.
476
+ */
477
+ private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION: CharacterSetValidation = {
478
+ minimumLength: 0,
479
+ maximumLength: 1,
480
+ component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
481
+ };
482
+
483
+ /**
484
+ * Validation parameters for zero-suppressed GTIN-12.
476
485
  */
477
486
  private static readonly ZERO_SUPPRESSED_GTIN12_VALIDATION: CharacterSetValidation = {
478
487
  minimumLength: 8,
@@ -526,6 +535,43 @@ export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
526
535
  PrefixManager.validatePrefix(this.prefixType, false, false, partialIdentificationKey, true, true, positionOffset);
527
536
  }
528
537
 
538
+ /**
539
+ * Zero suppress a GTIN-12.
540
+ *
541
+ * @param gtin12
542
+ * GTIN-12.
543
+ *
544
+ * @returns
545
+ * Zero-suppressed GTIN-12.
546
+ */
547
+ static zeroSuppress(gtin12: string): string {
548
+ GTIN12_VALIDATOR.validate(gtin12);
549
+
550
+ // Convert to individual digits.
551
+ const d = Array.from(gtin12);
552
+
553
+ let zeroSuppressedGTIN12: string | undefined;
554
+
555
+ // All rules require that digits in positions 1, 5, and 6 be zero.
556
+ if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
557
+ if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
558
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
559
+ } else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
560
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
561
+ } else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
562
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
563
+ } else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
564
+ zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
565
+ }
566
+ }
567
+
568
+ if (zeroSuppressedGTIN12 === undefined) {
569
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
570
+ }
571
+
572
+ return zeroSuppressedGTIN12;
573
+ }
574
+
529
575
  /**
530
576
  * Zero expand a zero-suppressed GTIN-12.
531
577
  *
@@ -566,6 +612,115 @@ export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
566
612
  return gtin12;
567
613
  }
568
614
 
615
+ /**
616
+ * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
617
+ *
618
+ * @param indicatorDigit
619
+ * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
620
+ *
621
+ * @param gtin
622
+ * GTIN.
623
+ *
624
+ * @returns
625
+ * GTIN-14.
626
+ */
627
+ static convertToGTIN14(indicatorDigit: string, gtin: string): string {
628
+ GTINCreator.validateAny(gtin);
629
+
630
+ NUMERIC_CREATOR.validate(indicatorDigit, GTINValidator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
631
+
632
+ const gtinLength = gtin.length;
633
+
634
+ // Check digit doesn't change by prepending zeros.
635
+ let gtin14 = "0".repeat(GTINType.GTIN14 - gtinLength) + gtin;
636
+
637
+ // If indicator digit provided and is different, recalculate the check digit.
638
+ if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
639
+ const partialGTIN14 = indicatorDigit + gtin14.substring(1, GTINType.GTIN14 - 1);
640
+
641
+ gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
642
+ }
643
+
644
+ return gtin14;
645
+ }
646
+
647
+ /**
648
+ * Normalize a GTIN of any length.
649
+ * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
650
+ * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
651
+ * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
652
+ * - Otherwise, the GTIN is unchanged.
653
+ *
654
+ * @param gtin
655
+ * GTIN.
656
+ *
657
+ * @returns
658
+ * Normalized GTIN.
659
+ */
660
+ static normalize(gtin: string): string {
661
+ const gtinLength = gtin.length;
662
+
663
+ let normalizedGTIN: string;
664
+
665
+ switch (gtinLength) {
666
+ case GTINType.GTIN13 as number:
667
+ if (!gtin.startsWith("0")) {
668
+ // GTIN is GTIN-13.
669
+ normalizedGTIN = gtin;
670
+ } else if (!gtin.startsWith("00000")) {
671
+ // GTIN is GTIN-12.
672
+ normalizedGTIN = gtin.substring(1);
673
+ } else if (!gtin.startsWith("000000")) {
674
+ // GTIN is GTIN-8.
675
+ normalizedGTIN = gtin.substring(5);
676
+ } else {
677
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
678
+ }
679
+ break;
680
+
681
+ case GTINType.GTIN12 as number:
682
+ // GTIN is GTIN-12.
683
+ normalizedGTIN = gtin;
684
+ break;
685
+
686
+ case GTINType.GTIN8 as number:
687
+ if (!gtin.startsWith("0")) {
688
+ // GTIN is GTIN-8.
689
+ normalizedGTIN = gtin;
690
+ } else {
691
+ // GTIN is zero-suppressed GTIN-12.
692
+ normalizedGTIN = GTINValidator.zeroExpand(gtin);
693
+ }
694
+ break;
695
+
696
+ case GTINType.GTIN14 as number:
697
+ if (!gtin.startsWith("0")) {
698
+ // GTIN is GTIN-14.
699
+ normalizedGTIN = gtin;
700
+ } else if (!gtin.startsWith("00")) {
701
+ // GTIN is GTIN-13.
702
+ normalizedGTIN = gtin.substring(1);
703
+ } else if (!gtin.startsWith("000000")) {
704
+ // GTIN is GTIN-12.
705
+ normalizedGTIN = gtin.substring(2);
706
+ } else if (!gtin.startsWith("0000000")) {
707
+ // GTIN is GTIN-8.
708
+ normalizedGTIN = gtin.substring(6);
709
+ } else {
710
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
711
+ }
712
+ break;
713
+
714
+ default:
715
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
716
+ }
717
+
718
+ // Validation applies to the normalized GTIN.
719
+ GTINCreator.validateAny(normalizedGTIN);
720
+
721
+ return normalizedGTIN;
722
+ }
723
+
569
724
  /**
570
725
  * Validate any GTIN, optionally against a level.
571
726
  *
@@ -1048,7 +1203,7 @@ export interface NumericIdentificationKeyCreator extends NumericIdentificationKe
1048
1203
  * @returns
1049
1204
  * Identification key(s).
1050
1205
  */
1051
- create: <T extends TransformerInput<number | bigint>>(valueOrValues: T, sparse?: boolean) => TransformerOutput<T, string>;
1206
+ create: <TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean) => TransformerOutput<TTransformerInput, string>;
1052
1207
 
1053
1208
  /**
1054
1209
  * Create all identification keys for the prefix from `0` to `capacity - 1`.
@@ -1134,7 +1289,7 @@ abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentific
1134
1289
  /**
1135
1290
  * @inheritDoc
1136
1291
  */
1137
- create<T extends TransformerInput<number | bigint>>(valueOrValues: T, sparse = false): TransformerOutput<T, string> {
1292
+ create<TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse = false): TransformerOutput<TTransformerInput, string> {
1138
1293
  return NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildIdentificationKey(reference));
1139
1294
  }
1140
1295
 
@@ -1224,15 +1379,6 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1224
1379
  component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1225
1380
  };
1226
1381
 
1227
- /**
1228
- * Validation parameters for optional indicator digit.
1229
- */
1230
- private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION: CharacterSetValidation = {
1231
- minimumLength: 0,
1232
- maximumLength: 1,
1233
- component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1234
- };
1235
-
1236
1382
  /**
1237
1383
  * Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
1238
1384
  *
@@ -1271,7 +1417,7 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1271
1417
  * @returns
1272
1418
  * GTIN-14(s).
1273
1419
  */
1274
- createGTIN14<T extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: T, sparse = false): TransformerOutput<T, string> {
1420
+ createGTIN14<TTransformerInput extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: TTransformerInput, sparse = false): TransformerOutput<TTransformerInput, string> {
1275
1421
  NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1276
1422
 
1277
1423
  return NUMERIC_CREATOR.create(GTINType.GTIN13 - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, Exclusion.None, sparse ? this.tweak : undefined, (reference) => {
@@ -1280,152 +1426,6 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1280
1426
  return partialIdentificationKey + checkDigit(partialIdentificationKey);
1281
1427
  });
1282
1428
  }
1283
-
1284
- /**
1285
- * Zero suppress a GTIN-12.
1286
- *
1287
- * @param gtin12
1288
- * GTIN-12.
1289
- *
1290
- * @returns
1291
- * Zero-suppressed GTIN-12.
1292
- */
1293
- static zeroSuppress(gtin12: string): string {
1294
- GTIN12_VALIDATOR.validate(gtin12);
1295
-
1296
- // Convert to individual digits.
1297
- const d = Array.from(gtin12);
1298
-
1299
- let zeroSuppressedGTIN12: string | undefined;
1300
-
1301
- // All rules require that digits in positions 1, 5, and 6 be zero.
1302
- if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
1303
- if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
1304
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
1305
- } else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
1306
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
1307
- } else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
1308
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
1309
- } else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
1310
- zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
1311
- }
1312
- }
1313
-
1314
- if (zeroSuppressedGTIN12 === undefined) {
1315
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
1316
- }
1317
-
1318
- return zeroSuppressedGTIN12;
1319
- }
1320
-
1321
- /**
1322
- * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
1323
- *
1324
- * @param indicatorDigit
1325
- * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
1326
- *
1327
- * @param gtin
1328
- * GTIN.
1329
- *
1330
- * @returns
1331
- * GTIN-14.
1332
- */
1333
- static convertToGTIN14(indicatorDigit: string, gtin: string): string {
1334
- GTINCreator.validateAny(gtin);
1335
-
1336
- NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
1337
-
1338
- const gtinLength = gtin.length;
1339
-
1340
- // Check digit doesn't change by prepending zeros.
1341
- let gtin14 = "0".repeat(GTINType.GTIN14 - gtinLength) + gtin;
1342
-
1343
- // If indicator digit provided and is different, recalculate the check digit.
1344
- if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
1345
- const partialGTIN14 = indicatorDigit + gtin14.substring(1, GTINType.GTIN14 - 1);
1346
-
1347
- gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
1348
- }
1349
-
1350
- return gtin14;
1351
- }
1352
-
1353
- /**
1354
- * Normalize a GTIN of any length.
1355
- * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
1356
- * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
1357
- * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
1358
- * - Otherwise, the GTIN is unchanged.
1359
- *
1360
- * @param gtin
1361
- * GTIN.
1362
- *
1363
- * @returns
1364
- * Normalized GTIN.
1365
- */
1366
- static normalize(gtin: string): string {
1367
- const gtinLength = gtin.length;
1368
-
1369
- let normalizedGTIN: string;
1370
-
1371
- switch (gtinLength) {
1372
- case GTINType.GTIN13 as number:
1373
- if (!gtin.startsWith("0")) {
1374
- // GTIN is GTIN-13.
1375
- normalizedGTIN = gtin;
1376
- } else if (!gtin.startsWith("00000")) {
1377
- // GTIN is GTIN-12.
1378
- normalizedGTIN = gtin.substring(1);
1379
- } else if (!gtin.startsWith("000000")) {
1380
- // GTIN is GTIN-8.
1381
- normalizedGTIN = gtin.substring(5);
1382
- } else {
1383
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
1384
- }
1385
- break;
1386
-
1387
- case GTINType.GTIN12 as number:
1388
- // GTIN is GTIN-12.
1389
- normalizedGTIN = gtin;
1390
- break;
1391
-
1392
- case GTINType.GTIN8 as number:
1393
- if (!gtin.startsWith("0")) {
1394
- // GTIN is GTIN-8.
1395
- normalizedGTIN = gtin;
1396
- } else {
1397
- // GTIN is zero-suppressed GTIN-12.
1398
- normalizedGTIN = GTINCreator.zeroExpand(gtin);
1399
- }
1400
- break;
1401
-
1402
- case GTINType.GTIN14 as number:
1403
- if (!gtin.startsWith("0")) {
1404
- // GTIN is GTIN-14.
1405
- normalizedGTIN = gtin;
1406
- } else if (!gtin.startsWith("00")) {
1407
- // GTIN is GTIN-13.
1408
- normalizedGTIN = gtin.substring(1);
1409
- } else if (!gtin.startsWith("000000")) {
1410
- // GTIN is GTIN-12.
1411
- normalizedGTIN = gtin.substring(2);
1412
- } else if (!gtin.startsWith("0000000")) {
1413
- // GTIN is GTIN-8.
1414
- normalizedGTIN = gtin.substring(6);
1415
- } else {
1416
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
1417
- }
1418
- break;
1419
-
1420
- default:
1421
- throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
1422
- }
1423
-
1424
- // Validation applies to the normalized GTIN.
1425
- GTINCreator.validateAny(normalizedGTIN);
1426
-
1427
- return normalizedGTIN;
1428
- }
1429
1429
  }
1430
1430
 
1431
1431
  /**
@@ -1496,7 +1496,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1496
1496
  * @returns
1497
1497
  * Serialized identification key(s).
1498
1498
  */
1499
- private concatenateValidated<T extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: T): TransformerOutput<T, string> {
1499
+ private concatenateValidated<TTransformerInput extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string> {
1500
1500
  // TODO Refactor type when https://github.com/microsoft/TypeScript/pull/56941 released.
1501
1501
  let result: string | Iterable<string>;
1502
1502
 
@@ -1525,7 +1525,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1525
1525
  }
1526
1526
 
1527
1527
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type determination is handled above.
1528
- return result as TransformerOutput<T, string>;
1528
+ return result as TransformerOutput<TTransformerInput, string>;
1529
1529
  }
1530
1530
 
1531
1531
  /**
@@ -1544,7 +1544,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1544
1544
  * @returns
1545
1545
  * Serialized identification keys.
1546
1546
  */
1547
- createSerialized<T extends TransformerInput<string>>(value: number, serialComponentOrComponents: T, sparse?: boolean): TransformerOutput<T, string> {
1547
+ createSerialized<TTransformerInput extends TransformerInput<string>>(value: number, serialComponentOrComponents: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string> {
1548
1548
  return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
1549
1549
  }
1550
1550
 
@@ -1560,7 +1560,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1560
1560
  * @returns
1561
1561
  * Serialized identification key(s).
1562
1562
  */
1563
- concatenate<T extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: T): TransformerOutput<T, string> {
1563
+ concatenate<TTransformerInput extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string> {
1564
1564
  this.validate(baseIdentificationKey);
1565
1565
 
1566
1566
  return this.concatenateValidated(baseIdentificationKey, serialComponentOrComponents);
@@ -1624,7 +1624,7 @@ export class NonNumericIdentificationKeyCreator extends Mixin(NonNumericIdentifi
1624
1624
  * @returns
1625
1625
  * Identification key(s).
1626
1626
  */
1627
- create<T extends TransformerInput<string>>(referenceOrReferences: T): TransformerOutput<T, string> {
1627
+ create<TTransformerInput extends TransformerInput<string>>(referenceOrReferences: TTransformerInput): TransformerOutput<TTransformerInput, string> {
1628
1628
  // TODO Refactor type when https://github.com/microsoft/TypeScript/pull/56941 released.
1629
1629
  let result: string | Iterable<string>;
1630
1630
 
@@ -1657,7 +1657,7 @@ export class NonNumericIdentificationKeyCreator extends Mixin(NonNumericIdentifi
1657
1657
  }
1658
1658
 
1659
1659
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type determination is handled above.
1660
- return result as TransformerOutput<T, string>;
1660
+ return result as TransformerOutput<TTransformerInput, string>;
1661
1661
  }
1662
1662
  }
1663
1663
 
@@ -2076,9 +2076,9 @@ export class PrefixManager {
2076
2076
  * @returns
2077
2077
  * Identification key creator.
2078
2078
  */
2079
- private getIdentificationKeyCreator<T extends IdentificationKeyCreator>(identificationKeyType: IdentificationKeyType, constructorCallback: () => T): T {
2079
+ private getIdentificationKeyCreator<TIdentificationKeyCreator extends IdentificationKeyCreator>(identificationKeyType: IdentificationKeyType, constructorCallback: () => TIdentificationKeyCreator): TIdentificationKeyCreator {
2080
2080
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is paired with constructor callback.
2081
- let creator = this._identificationKeyCreatorsMap.get(identificationKeyType) as (T | undefined);
2081
+ let creator = this._identificationKeyCreatorsMap.get(identificationKeyType) as (TIdentificationKeyCreator | undefined);
2082
2082
 
2083
2083
  if (creator === undefined) {
2084
2084
  if (this.prefixType === PrefixType.GS18Prefix && identificationKeyType !== IdentificationKeyType.GTIN) {