Skip to content

Commit a4f0719

Browse files
committed
refactor: add explicit undefined to optional properties
Update optional property types to include explicit | undefined for exactOptionalPropertyTypes TypeScript compliance.
1 parent d399970 commit a4f0719

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/package-url.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ export type PackageURLComponentValue = string | QualifiersObject | undefined
5959
* Contains all package URL components as properties.
6060
*/
6161
export type PackageURLObject = {
62-
type?: string
63-
namespace?: string
64-
name?: string
65-
version?: string
66-
qualifiers?: QualifiersObject
67-
subpath?: string
62+
type?: string | undefined
63+
namespace?: string | undefined
64+
name?: string | undefined
65+
version?: string | undefined
66+
qualifiers?: QualifiersObject | undefined
67+
subpath?: string | undefined
6868
}
6969

7070
// Pattern to match URLs with schemes other than "pkg".

src/validate.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function validateEmptyByType(
2121
type: string,
2222
name: string,
2323
value: unknown,
24-
options?: { throws?: boolean } | boolean,
24+
options?: { throws?: boolean | undefined } | boolean | undefined,
2525
): boolean {
2626
// Support both legacy boolean parameter and new options object for backward compatibility.
2727
const { throws = false } =
@@ -41,7 +41,7 @@ function validateEmptyByType(
4141
*/
4242
function validateName(
4343
name: unknown,
44-
options?: { throws?: boolean } | boolean,
44+
options?: { throws?: boolean | undefined } | boolean | undefined,
4545
): boolean {
4646
// Support both legacy boolean parameter and new options object for backward compatibility.
4747
const opts = typeof options === 'boolean' ? { throws: options } : options
@@ -56,7 +56,7 @@ function validateName(
5656
*/
5757
function validateNamespace(
5858
namespace: unknown,
59-
options?: { throws?: boolean } | boolean,
59+
options?: { throws?: boolean | undefined } | boolean | undefined,
6060
): boolean {
6161
// Support both legacy boolean parameter and new options object for backward compatibility.
6262
const opts = typeof options === 'boolean' ? { throws: options } : options
@@ -69,7 +69,7 @@ function validateNamespace(
6969
*/
7070
function validateQualifierKey(
7171
key: string,
72-
options?: { throws?: boolean } | boolean,
72+
options?: { throws?: boolean | undefined } | boolean | undefined,
7373
): boolean {
7474
// Support both legacy boolean parameter and new options object for backward compatibility.
7575
const opts = typeof options === 'boolean' ? { throws: options } : options
@@ -116,7 +116,7 @@ function validateQualifierKey(
116116
*/
117117
function validateQualifiers(
118118
qualifiers: unknown,
119-
options?: { throws?: boolean } | boolean,
119+
options?: { throws?: boolean | undefined } | boolean | undefined,
120120
): boolean {
121121
// Support both legacy boolean parameter and new options object for backward compatibility.
122122
const opts = typeof options === 'boolean' ? { throws: options } : options
@@ -157,7 +157,7 @@ function validateQualifiers(
157157
function validateRequired(
158158
name: string,
159159
value: unknown,
160-
options?: { throws?: boolean } | boolean,
160+
options?: { throws?: boolean | undefined } | boolean | undefined,
161161
): boolean {
162162
// Support both legacy boolean parameter and new options object for backward compatibility.
163163
const { throws = false } =
@@ -179,7 +179,7 @@ function validateRequiredByType(
179179
type: string,
180180
name: string,
181181
value: unknown,
182-
options?: { throws?: boolean } | boolean,
182+
options?: { throws?: boolean | undefined } | boolean | undefined,
183183
): boolean {
184184
// Support both legacy boolean parameter and new options object for backward compatibility.
185185
const { throws = false } =
@@ -200,7 +200,7 @@ function validateRequiredByType(
200200
function validateStartsWithoutNumber(
201201
name: string,
202202
value: string,
203-
options?: { throws?: boolean } | boolean,
203+
options?: { throws?: boolean | undefined } | boolean | undefined,
204204
): boolean {
205205
// Support both legacy boolean parameter and new options object for backward compatibility.
206206
const { throws = false } =
@@ -224,7 +224,7 @@ function validateStartsWithoutNumber(
224224
function validateStrings(
225225
name: string,
226226
value: unknown,
227-
options?: { throws?: boolean } | boolean,
227+
options?: { throws?: boolean | undefined } | boolean | undefined,
228228
): boolean {
229229
// Support both legacy boolean parameter and new options object for backward compatibility.
230230
const { throws = false } =
@@ -244,7 +244,7 @@ function validateStrings(
244244
*/
245245
function validateSubpath(
246246
subpath: unknown,
247-
options?: { throws?: boolean } | boolean,
247+
options?: { throws?: boolean | undefined } | boolean | undefined,
248248
): boolean {
249249
// Support both legacy boolean parameter and new options object for backward compatibility.
250250
const opts = typeof options === 'boolean' ? { throws: options } : options
@@ -257,7 +257,7 @@ function validateSubpath(
257257
*/
258258
function validateType(
259259
type: unknown,
260-
options?: { throws?: boolean } | boolean,
260+
options?: { throws?: boolean | undefined } | boolean | undefined,
261261
): boolean {
262262
// Support both legacy boolean parameter and new options object for backward compatibility.
263263
const opts = typeof options === 'boolean' ? { throws: options } : options
@@ -307,7 +307,7 @@ function validateType(
307307
*/
308308
function validateVersion(
309309
version: unknown,
310-
options?: { throws?: boolean } | boolean,
310+
options?: { throws?: boolean | undefined } | boolean | undefined,
311311
): boolean {
312312
// Support both legacy boolean parameter and new options object for backward compatibility.
313313
const opts = typeof options === 'boolean' ? { throws: options } : options

0 commit comments

Comments
 (0)