Skip to content

Commit 2846a41

Browse files
authored
fix: fixed some typing for plugin options (#1455)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent b5ee59e commit 2846a41

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
66

77
<!-- unreleased changes go here -->
88

9+
* Fixed
10+
* typing for plugin options of enums support literals, too (via [#1455])
11+
12+
[#1455]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/1455
13+
914
## 5.2.0 - 2025-10-29
1015

1116
* Added

src/plugin.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,9 @@ export interface CycloneDxWebpackPluginOptions {
130130
collectEvidence?: CycloneDxWebpackPlugin['collectEvidence']
131131
}
132132

133-
class ValidationError extends Error {
134-
readonly details: any
135-
constructor (message: string, details: any) {
136-
super(message)
137-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- expected */
138-
this.details = details
139-
}
140-
}
141-
142133
/** @public */
143134
export class CycloneDxWebpackPlugin {
144-
specVersion: CDX.Spec.Version
135+
specVersion: CDX.Spec.Version | `${CDX.Spec.Version}`
145136
reproducibleResults: boolean
146137
validateResults: boolean
147138

@@ -150,7 +141,7 @@ export class CycloneDxWebpackPlugin {
150141
resultWellknown: string | undefined
151142

152143
rootComponentAutodetect: boolean
153-
rootComponentType: CDX.Models.Component['type']
144+
rootComponentType: CDX.Models.Component['type'] | `${CDX.Models.Component['type']}`
154145
rootComponentName: CDX.Models.Component['name'] | undefined
155146
rootComponentVersion: CDX.Models.Component['version'] | undefined
156147
rootComponentBuildSystem: CDX.Models.ExternalReference['url'] | undefined
@@ -420,7 +411,8 @@ export class CycloneDxWebpackPlugin {
420411

421412
if (bom.metadata.component !== undefined) {
422413
this.#addRootComponentExtRefs(bom.metadata.component, logger)
423-
bom.metadata.component.type = this.rootComponentType
414+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ack */
415+
bom.metadata.component.type = this.rootComponentType as CDX.Models.Component['type']
424416
bom.metadata.component.purl = cdxPurlFactory.makeFromComponent(bom.metadata.component)
425417
bom.metadata.component.bomRef.value = bom.metadata.component.purl?.toString()
426418
}
@@ -465,3 +457,12 @@ export class CycloneDxWebpackPlugin {
465457
}
466458
}
467459
}
460+
461+
class ValidationError extends Error {
462+
readonly details: any
463+
constructor (message: string, details: any) {
464+
super(message)
465+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- expected */
466+
this.details = details
467+
}
468+
}

0 commit comments

Comments
 (0)