Removed forgotter useless parameters and fixed nfc method to accept null;

Added null to more signatures;
This commit is contained in:
Alexander Cerutti
2019-06-30 02:06:55 +02:00
parent 4546774916
commit 1226bb21c7

View File

@@ -207,7 +207,7 @@ export class Pass implements PassIndexSignature {
* @see https://apple.co/2KOv0OW - Passes support localization * @see https://apple.co/2KOv0OW - Passes support localization
*/ */
localize(lang?: string, translations?: { [key: string]: string }): this { localize(lang: string, translations?: { [key: string]: string }): this {
if (lang && typeof lang === "string" && (typeof translations === "object" || translations === undefined)) { if (lang && typeof lang === "string" && (typeof translations === "object" || translations === undefined)) {
this.l10nTranslations[lang] = translations || {}; this.l10nTranslations[lang] = translations || {};
} }
@@ -223,7 +223,7 @@ export class Pass implements PassIndexSignature {
* @returns {this} * @returns {this}
*/ */
expiration(date?: Date): this | string { expiration(date: Date | null): this | string {
if (date === null) { if (date === null) {
delete this[passProps]["expirationDate"]; delete this[passProps]["expirationDate"];
return this; return this;
@@ -277,7 +277,7 @@ export class Pass implements PassIndexSignature {
* @returns {Pass} * @returns {Pass}
*/ */
locations(...data: schema.Location[]): this { locations(...data: schema.Location[] | null): this {
if (data === null) { if (data === null) {
delete this[passProps]["locations"]; delete this[passProps]["locations"];
return this; return this;
@@ -298,7 +298,7 @@ export class Pass implements PassIndexSignature {
* @returns {Pass} * @returns {Pass}
*/ */
relevantDate(date?: Date): this | string { relevantDate(date: Date | null): this | string {
if (date === null) { if (date === null) {
delete this[passProps]["relevantDate"]; delete this[passProps]["relevantDate"];
return this; return this;
@@ -322,7 +322,7 @@ export class Pass implements PassIndexSignature {
* @return {this} Improved this with length property and other methods * @return {this} Improved this with length property and other methods
*/ */
barcodes(first?: string | schema.Barcode, ...data: schema.Barcode[]): this { barcodes(first: null | string | schema.Barcode, ...data: schema.Barcode[]): this {
if (first === null) { if (first === null) {
delete this[passProps]["barcodes"]; delete this[passProps]["barcodes"];
return this; return this;
@@ -436,9 +436,10 @@ export class Pass implements PassIndexSignature {
* @returns {this} * @returns {this}
*/ */
nfc(data?: schema.NFC): this | schema.NFC { nfc(data: schema.NFC | null): this | schema.NFC {
if (data === undefined) { if (data === null) {
return this[passProps]["nfc"]; delete this[passProps]["nfc"];
return this;
} }
if (!(typeof data === "object" && !Array.isArray(data) && schema.isValid(data, "nfcDict"))) { if (!(typeof data === "object" && !Array.isArray(data) && schema.isValid(data, "nfcDict"))) {