From b6b57215a89e38b00256ac2e65c606429b954997 Mon Sep 17 00:00:00 2001 From: Blake Thomas Williams <49404493+btw17@users.noreply.github.com> Date: Fri, 15 Mar 2024 16:45:16 -0500 Subject: [PATCH] fix: updated field_dropdown to properly infer its Field type with TS 5.3.3 (#7939) * fix: updated field_dropdown to properly infer its Field type with TS 5.3.3 * fix: removed undefined as an option as its not needed for the type fix * fix: updated field_dropdown to allow |undefined class validation --- core/field_dropdown.ts | 10 ++++++++-- package-lock.json | 8 ++++---- package.json | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/field_dropdown.ts b/core/field_dropdown.ts index ad728f226..6fb779c4f 100644 --- a/core/field_dropdown.ts +++ b/core/field_dropdown.ts @@ -408,7 +408,13 @@ export class FieldDropdown extends Field { * @param newValue The input value. * @returns A valid language-neutral option, or null if invalid. */ - protected override doClassValidation_(newValue?: string): string | null { + protected override doClassValidation_( + newValue: string, + ): string | null | undefined; + protected override doClassValidation_(newValue?: string): string | null; + protected override doClassValidation_( + newValue?: string, + ): string | null | undefined { const options = this.getOptions(true); const isValueValid = options.some((option) => option[1] === newValue); @@ -426,7 +432,7 @@ export class FieldDropdown extends Field { } return null; } - return newValue as string; + return newValue; } /** diff --git a/package-lock.json b/package-lock.json index 20e03a097..f0ec9fc4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "prettier": "3.2.5", "readline-sync": "^1.4.10", "rimraf": "^5.0.0", - "typescript": "^5.0.2", + "typescript": "^5.3.3", "webdriverio": "^8.32.2", "yargs": "^17.2.1" } @@ -10885,9 +10885,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", + "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index a7ac581f0..ecfe593ce 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "prettier": "3.2.5", "readline-sync": "^1.4.10", "rimraf": "^5.0.0", - "typescript": "^5.0.2", + "typescript": "^5.3.3", "webdriverio": "^8.32.2", "yargs": "^17.2.1" },