Convert providers/summary/ and providers/index to TypeScript#1550
Convert providers/summary/ and providers/index to TypeScript#1550JamieMagee merged 9 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes the TypeScript conversion for the providers/summary/ module set (tool summarizers + registry) and converts providers/index (central provider registry) to TypeScript, updating downstream imports and tests to use .ts entrypoints.
Changes:
- Replace
providers/summary/*.{js,d.ts}pairs with consolidated.tsimplementations (ScanCode legacy/new, FOSSology, Licensee, REUSE, CdSource; plus updated ClearlyDefined). - Update
providers/summary/index.tsto export a typed runtimesummaryProvidersobject, and update callers/tests to import.ts. - Convert
providers/indexto a typed TS provider registry and updatebin/config.jsto import it.
Show a summary per file
| File | Description |
|---|---|
| test/summary/scancode.ts | Updates ScanCode summarizer imports to .ts. |
| test/summary/reuse.ts | Updates REUSE summarizer import to .ts. |
| test/summary/licensee.ts | Updates Licensee summarizer import to .ts. |
| test/summary/fossology.ts | Updates FOSSology summarizer import to .ts. |
| test/summary/clearlydefinedTests.ts | Updates ClearlyDefined summarizer import to .ts. |
| test/summary/clearlyDefined.ts | Updates ClearlyDefined summarizer import to .ts. |
| test/providers/summary/scancode/new-summarizer.mts | Updates ScanCode summarizer import to .ts. |
| test/providers/summary/scancode/legacy-summarizer.mts | Updates ScanCode summarizer import to .ts. |
| test/providers/summary/fossology.mts | Updates FOSSology summarizer import to .ts. |
| providers/summary/scancode/new-summarizer.ts | Adds TS implementation for ScanCode “new” summarizer. |
| providers/summary/scancode/new-summarizer.js | Removes legacy JS implementation (replaced by TS). |
| providers/summary/scancode/new-summarizer.d.ts | Removes standalone typings (now in TS source). |
| providers/summary/scancode/legacy-summarizer.ts | Adds TS implementation for ScanCode “legacy” summarizer. |
| providers/summary/scancode/legacy-summarizer.js | Removes legacy JS implementation (replaced by TS). |
| providers/summary/scancode/legacy-summarizer.d.ts | Removes standalone typings (now in TS source). |
| providers/summary/scancode.ts | Converts ScanCode delegator to TS runtime class/export. |
| providers/summary/scancode.js | Removes legacy JS delegator (replaced by TS). |
| providers/summary/reuse.ts | Adds TS implementation for REUSE summarizer. |
| providers/summary/reuse.js | Removes legacy JS implementation (replaced by TS). |
| providers/summary/reuse.d.ts | Removes standalone typings (now in TS source). |
| providers/summary/licensee.ts | Adds TS implementation for Licensee summarizer. |
| providers/summary/licensee.js | Removes legacy JS implementation (replaced by TS). |
| providers/summary/licensee.d.ts | Removes standalone typings (now in TS source). |
| providers/summary/index.ts | Converts summary provider registry to typed TS runtime object. |
| providers/summary/index.js | Removes legacy JS registry (replaced by TS). |
| providers/summary/fossology.ts | Adds TS implementation for FOSSology summarizer. |
| providers/summary/fossology.js | Removes legacy JS implementation (replaced by TS). |
| providers/summary/fossology.d.ts | Removes standalone typings (now in TS source). |
| providers/summary/clearlydefined.ts | Updates ClearlyDefined summarizer to TS-native types/exports. |
| providers/summary/clearlydefined.d.ts | Removes standalone typings (now in TS source). |
| providers/summary/cdsource.ts | Adds TS implementation for CdSource summarizer. |
| providers/summary/cdsource.js | Removes legacy JS implementation (replaced by TS). |
| providers/summary/cdsource.d.ts | Removes standalone typings (now in TS source). |
| providers/index.ts | Converts central providers registry to TS with typed interfaces and runtime object. |
| providers/index.js | Removes legacy JS registry (replaced by TS). |
| business/summarizer.js | Updates summary registry import to .ts. |
| bin/config.js | Updates providers registry import to .ts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (7)
providers/summary/clearlydefined.ts:206
- The default export accepts
options?, butClearlyDescribedSummarizer's constructor requires a non-optionalSummarizerOptions, which will failtscwhen callers omit options. Make the constructor param optional/defaulted, or coalesceoptions ?? {}in the factory.
providers/summary/scancode.ts:132 - The factory signature allows
optionsto be omitted, butScanCodeSummarizer's constructor requires a non-optionalSummarizerOptions. This will fail type-checking when the summarizer is constructed without options (which current tests do). Consider defaultingoptionsin the constructor or factory.
providers/summary/scancode/new-summarizer.ts:193 licenseExpressionsis typed asSet<string>, butmatch.spdx_license_expressionis optional. Adding it without checking will failtscand can propagateundefinedinto license joining. Guard onmatch.spdx_license_expression(and/or narrow the match type) beforeadd.
_getLicenseExpressionFromFileLicenseDetections(file: ScanCodeFile): string | null {
if (!file.license_detections) {
return null
}
const licenseExpressions = file.license_detections.reduce(
(licenseExpressions: Set<string>, licenseDetection: ScanCodeLicenseDetection) => {
if (licenseDetection.license_expression_spdx) {
licenseExpressions.add(licenseDetection.license_expression_spdx)
} else if (licenseDetection.matches) {
for (const match of licenseDetection.matches as { score?: number; spdx_license_expression?: string }[]) {
// Only consider matches with a reasonably high score of 80 or higher
if (match.score >= 80) {
licenseExpressions.add(match.spdx_license_expression)
}
}
providers/summary/scancode/legacy-summarizer.ts:206
addArrayToSetis given aSet<string>but the value extractor can returnundefined(license.license || license.spdx_license_key). This won’t type-check and may add invalid values. Ensure the extractor always returns a string (e.g., filter entries first or return a default / narrow) before joining expressions.
_getLicenseByPackageAssertion(files: ScanCodeFile[]): string | null {
for (const file of files) {
const asserted = get(file, 'packages[0].asserted_licenses') as
| { license?: string; spdx_license_key?: string }[]
| undefined
// Find the first package file and treat it as the authority
if (asserted) {
const packageLicenses = addArrayToSet(
asserted,
new Set<string>(),
// TODO, is `license.license` real?
license => license.license || license.spdx_license_key
)
return joinExpressions(packageLicenses)
providers/summary/scancode/legacy-summarizer.ts:230
licensesis used withjoinExpressions(expectsSet<string>), but the mapped values come from optional fields and_createExpressionFromLicense()can returnnull. This will failtsc. Narrow/filter tostringvalues (e.g., use a type guard) and type the set asSet<string>before callingjoinExpressions.
const asserted = get(file, 'packages[0].asserted_licenses') as ScanCodeLicense[] | undefined
const fileLicense = asserted || file.licenses || []
let licenses = new Set(fileLicense.map((x: ScanCodeLicense) => x.license).filter((x: unknown) => x))
if (!licenses.size) {
licenses = new Set(
fileLicense
.filter((x: ScanCodeLicense) => x.score !== undefined && x.score >= 80)
.map((x: ScanCodeLicense) => this._createExpressionFromLicense(x))
)
}
const licenseExpression = joinExpressions(licenses)
setIfValue(result, 'license', licenseExpression)
providers/summary/clearlydefined.ts:701
Array.prototype.findcan returnundefined, so accessing.Pathdirectly is a TypeScript error understrictNullChecksand can throw at runtime if no entry matches the architecture. Handle the not-found case (e.g., check the found entry and throw/return) or use a safe fallback.
This issue also appears on line 715 of the same file.
providers/summary/clearlydefined.ts:723
- Same issue as above:
.find(...)may returnundefined, so.Pathaccess will failtscand can throw at runtime. Add a guard for the missing entry before constructing the download URL.
- Files reviewed: 29/37 changed files
- Comments generated: 8
032efd3 to
4ddc6a9
Compare
1d826cf to
1b2c208
Compare
016856f to
67642ad
Compare
1b2c208 to
9619521
Compare
67642ad to
ce3272c
Compare
9619521 to
2751711
Compare
ce3272c to
c54bc5f
Compare
There was a problem hiding this comment.
Pull request overview
Migrates the providers/summary/ module set and the top-level providers registry to native TypeScript (Node 24 type-stripping), and updates call sites/tests to import the new .ts modules directly.
Changes:
- Replaced multiple
.js+.d.tspairs inproviders/summary/with.tsimplementations (and updated summary provider registry wiring). - Converted
providers/indexregistry to a typedproviders/index.tsexport and updated consumers to import it. - Updated tests and service code to import summarizers from
.tsentrypoints.
Show a summary per file
| File | Description |
|---|---|
| test/summary/scancode.ts | Update imports to .ts scancode summarizers. |
| test/summary/reuse.ts | Update import to .ts REUSE summarizer. |
| test/summary/licensee.ts | Update import to .ts Licensee summarizer. |
| test/summary/fossology.ts | Update import to .ts FOSSology summarizer. |
| test/summary/clearlydefinedTests.ts | Update import to .ts ClearlyDefined summarizer. |
| test/summary/clearlyDefined.ts | Update import to .ts ClearlyDefined summarizer. |
| test/providers/summary/scancode/new-summarizer.mts | Update import to .ts scancode summarizer. |
| test/providers/summary/scancode/legacy-summarizer.mts | Update import to .ts scancode summarizer. |
| test/providers/summary/fossology.mts | Update import to .ts FOSSology summarizer. |
| providers/summary/scancode/new-summarizer.ts | Add TS implementation of ScanCode “new” summarizer. |
| providers/summary/scancode/new-summarizer.js | Remove legacy JS implementation (replaced by TS). |
| providers/summary/scancode/new-summarizer.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/summary/scancode/legacy-summarizer.ts | Add TS implementation of ScanCode “legacy” summarizer. |
| providers/summary/scancode/legacy-summarizer.js | Remove legacy JS implementation (replaced by TS). |
| providers/summary/scancode/legacy-summarizer.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/summary/scancode.ts | Convert delegator to TS class and route to legacy/new summarizers. |
| providers/summary/scancode.js | Remove legacy JS delegator (replaced by TS). |
| providers/summary/reuse.ts | Add TS implementation of REUSE summarizer. |
| providers/summary/reuse.js | Remove legacy JS implementation (replaced by TS). |
| providers/summary/reuse.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/summary/licensee.ts | Add TS implementation of Licensee summarizer. |
| providers/summary/licensee.js | Remove legacy JS implementation (replaced by TS). |
| providers/summary/licensee.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/summary/index.ts | Update summary provider registry to TS imports/exports. |
| providers/summary/index.js | Remove legacy JS registry (replaced by TS). |
| providers/summary/fossology.ts | Add TS implementation of FOSSology summarizer. |
| providers/summary/fossology.js | Remove legacy JS implementation (replaced by TS). |
| providers/summary/fossology.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/summary/clearlydefined.ts | Refactor existing file toward TS-native typings and exports. |
| providers/summary/clearlydefined.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/summary/cdsource.ts | Add TS implementation of CdSource summarizer. |
| providers/summary/cdsource.js | Remove legacy JS implementation (replaced by TS). |
| providers/summary/cdsource.d.ts | Remove legacy type declarations (replaced by TS). |
| providers/index.ts | Convert provider registry export to a typed TS module. |
| providers/index.js | Remove legacy JS registry (replaced by TS). |
| business/summarizer.js | Update summarizer registry import to .ts. |
| bin/config.js | Update provider registry import to .ts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (7)
providers/summary/scancode.ts:132
- The factory
export default (options?: SummarizerOptions, logger?: Logger) => new ScanCodeSummarizer(options, logger)passes possibly-undefinedoptions/loggerinto a constructor that currently requiresoptions: SummarizerOptionsandlogger: Logger. This will not type-check understrictNullChecks. Make the constructor accept optional values (and/or defaultoptionsto{}) and align theoptionsproperty type accordingly.
This issue also appears on line 149 of the same file.
providers/summary/scancode.ts:149
export default (options?: SummarizerOptions, logger?: Logger) => new ScanCodeSummarizer(options, logger)still passes possibly-undefined values; even with a default parameter,logger?: Loggeris not assignable toLoggerat the callsite. Adjust the factory to omit the argument when undefined (or change the constructor parameter types) so this type-checks cleanly.
providers/summary/clearlydefined.ts:702registryData.find(...)can returnundefined, but the result is used immediately (...find(...).Path). TypeScript will flag this, and at runtime it will throw if the expected entry isn’t present (e.g., unexpectedArchitecture). Add a guard or fallback whenfindreturnsundefinedbefore building the download URL.
This issue also appears on line 715 of the same file.
providers/summary/clearlydefined.ts:721
registryData.find(...)can returnundefined, but.Pathis accessed unconditionally when constructing the Debian source download URL. This is a runtime throw risk and will not type-check in TS. Guard for missing entries (and decide what to do when no.orig.tar.*entry exists).
providers/summary/clearlydefined.ts:760- The default export passes
options?: SummarizerOptionsintonew ClearlyDescribedSummarizer(options), but the constructor currently requiresoptions: SummarizerOptions. This won’t type-check understrictNullChecks. Either make the constructor parameter optional with a default (e.g.,{}) or make the factory require an options object.
providers/summary/scancode/new-summarizer.ts:194 ScanCodeNewSummarizerusesmatch.score >= 80wherescoreis optional, which won’t type-check. Add an explicit guard forscorebeing defined before comparing, similar to other score checks in the code.
licenseExpressions.add(licenseDetection.license_expression_spdx)
} else if (licenseDetection.matches) {
for (const match of licenseDetection.matches as { score?: number; spdx_license_expression?: string }[]) {
// Only consider matches with a reasonably high score of 80 or higher
if (match.score >= 80 && match.spdx_license_expression) {
licenseExpressions.add(match.spdx_license_expression)
}
}
}
providers/index.ts:224
- The exported
providersobject now includesharvest.throttler.filter, but theProviders/HarvestProviderstype definitions in this file don’t declare athrottlerproperty. This makesconst providers: Providers = { ... }fail type-checking (and the registry type is missing a supported provider group). Addthrottlerto the relevant interfaces (or remove the object entry if it’s not meant to be part of the registry).
- Files reviewed: 29/37 changed files
- Comments generated: 5
There was a problem hiding this comment.
Pull request overview
Migrates the “summary” provider implementations (and the central providers registry) from paired .js/.d.ts files to consolidated .ts modules, and updates runtime/tests to import the new TypeScript entrypoints.
Changes:
- Convert summary providers (ScanCode, FOSSology, Licensee, REUSE, CdSource, ClearlyDefined) to TypeScript and remove legacy
.js/.d.tspairs. - Update
providers/summary/index.tsandproviders/index.tsto be concrete registries (instead of declaration-only typing / JS objects). - Update tests and consuming modules to import
.tsmodules.
Show a summary per file
| File | Description |
|---|---|
| test/summary/scancode.ts | Update imports to new .ts ScanCode summarizers. |
| test/summary/reuse.ts | Update import to providers/summary/reuse.ts. |
| test/summary/licensee.ts | Update import to providers/summary/licensee.ts. |
| test/summary/fossology.ts | Update import to providers/summary/fossology.ts. |
| test/summary/clearlydefinedTests.ts | Update import to providers/summary/clearlydefined.ts. |
| test/summary/clearlyDefined.ts | Update import to providers/summary/clearlydefined.ts. |
| test/providers/summary/scancode/new-summarizer.mts | Update import to providers/summary/scancode.ts. |
| test/providers/summary/scancode/legacy-summarizer.mts | Update import to providers/summary/scancode.ts. |
| test/providers/summary/fossology.mts | Update import to providers/summary/fossology.ts. |
| providers/summary/scancode/new-summarizer.ts | New TypeScript implementation for ScanCode “new” summarizer. |
| providers/summary/scancode/new-summarizer.js | Removed legacy JS implementation (replaced by .ts). |
| providers/summary/scancode/new-summarizer.d.ts | Removed legacy type declarations (now in .ts). |
| providers/summary/scancode/legacy-summarizer.ts | New TypeScript implementation for ScanCode “legacy” summarizer. |
| providers/summary/scancode/legacy-summarizer.js | Removed legacy JS implementation (replaced by .ts). |
| providers/summary/scancode/legacy-summarizer.d.ts | Removed legacy type declarations (now in .ts). |
| providers/summary/scancode.ts | Convert ScanCode delegator to TypeScript implementation. |
| providers/summary/scancode.js | Removed legacy JS delegator (replaced by .ts). |
| providers/summary/reuse.ts | New TypeScript implementation for REUSE summarizer. |
| providers/summary/reuse.js | Removed legacy JS implementation (replaced by .ts). |
| providers/summary/reuse.d.ts | Removed legacy type declarations (now in .ts). |
| providers/summary/licensee.ts | New TypeScript implementation for Licensee summarizer. |
| providers/summary/licensee.js | Removed legacy JS implementation (replaced by .ts). |
| providers/summary/licensee.d.ts | Removed legacy type declarations (now in .ts). |
| providers/summary/index.ts | Convert summary provider registry to concrete TS object exporting factories. |
| providers/summary/index.js | Removed legacy JS registry (replaced by .ts). |
| providers/summary/fossology.ts | New TypeScript implementation for FOSSology summarizer. |
| providers/summary/fossology.js | Removed legacy JS implementation (replaced by .ts). |
| providers/summary/fossology.d.ts | Removed legacy type declarations (now in .ts). |
| providers/summary/clearlydefined.ts | Migrate ClearlyDefined summarizer typings into .ts implementation. |
| providers/summary/clearlydefined.d.ts | Removed legacy type declarations (now in .ts). |
| providers/summary/cdsource.ts | New TypeScript implementation for CdSource summarizer. |
| providers/summary/cdsource.js | Removed legacy JS implementation (replaced by .ts). |
| providers/summary/cdsource.d.ts | Removed legacy type declarations (now in .ts). |
| providers/index.ts | Convert central provider registry to concrete TS object exporting factories. |
| providers/index.js | Removed legacy JS provider registry (replaced by .ts). |
| business/summarizer.js | Update summary registry import to providers/summary/index.ts. |
| bin/config.js | Update providers registry import to providers/index.ts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (2)
providers/summary/clearlydefined.ts:760
- The factory takes
options?: SummarizerOptionsbut passes it tonew ClearlyDescribedSummarizer(options)where the constructor requiresSummarizerOptions. This is a TypeScript type error (and tests call the factory with no args). Update the constructor to accept optional options (or default to{}), or make the factory parameter non-optional with a default.
providers/summary/scancode.ts:149 - The default export accepts
options?: SummarizerOptionsandlogger?: Loggerand forwards them tonew ScanCodeSummarizer(options, logger), but the constructor parameters are non-optional. This is astrictNullCheckstype error; prefer defaulted (non-optional) factory params or widen constructor param types and default internally.
- Files reviewed: 29/37 changed files
- Comments generated: 4
There was a problem hiding this comment.
Pull request overview
This PR continues the TypeScript migration by consolidating the providers/summary/ implementations (and their registries) into .ts sources, removing the prior .js + .d.ts pairs, and updating runtime/tests to import the new .ts entrypoints. It also converts providers/index to TypeScript to keep the central provider registry aligned with the repo’s Node 24 ESM + native TS type-stripping setup.
Changes:
- Migrate summary providers (ScanCode, ClearlyDefined, FOSSology, Licensee, REUSE, CdSource) to TypeScript and remove legacy
.js/.d.tsartifacts. - Rebuild
providers/summary/index.tsandproviders/index.tsas concrete registries (instead of declared-only typing). - Update tests and runtime modules to import
*.tsprovider entrypoints.
Show a summary per file
| File | Description |
|---|---|
| test/summary/scancode.ts | Updates imports to providers/summary/scancode*.ts. |
| test/summary/reuse.ts | Updates import to providers/summary/reuse.ts. |
| test/summary/licensee.ts | Updates import to providers/summary/licensee.ts. |
| test/summary/fossology.ts | Updates import to providers/summary/fossology.ts. |
| test/summary/clearlydefinedTests.ts | Updates import to providers/summary/clearlydefined.ts. |
| test/summary/clearlyDefined.ts | Updates import to providers/summary/clearlydefined.ts. |
| test/providers/summary/scancode/new-summarizer.mts | Updates import to providers/summary/scancode.ts. |
| test/providers/summary/scancode/legacy-summarizer.mts | Updates import to providers/summary/scancode.ts. |
| test/providers/summary/fossology.mts | Updates import to providers/summary/fossology.ts. |
| providers/summary/scancode/new-summarizer.ts | New TS implementation of ScanCode “new” summarizer. |
| providers/summary/scancode/new-summarizer.js | Removes legacy JS implementation. |
| providers/summary/scancode/new-summarizer.d.ts | Removes legacy generated typings. |
| providers/summary/scancode/legacy-summarizer.ts | New TS implementation of ScanCode “legacy” summarizer. |
| providers/summary/scancode/legacy-summarizer.js | Removes legacy JS implementation. |
| providers/summary/scancode/legacy-summarizer.d.ts | Removes legacy generated typings. |
| providers/summary/scancode.ts | Converts ScanCode delegator to TS implementation and updates imports. |
| providers/summary/scancode.js | Removes legacy JS delegator. |
| providers/summary/reuse.ts | New TS implementation of REUSE summarizer. |
| providers/summary/reuse.js | Removes legacy JS implementation. |
| providers/summary/reuse.d.ts | Removes legacy generated typings. |
| providers/summary/licensee.ts | New TS implementation of Licensee summarizer. |
| providers/summary/licensee.js | Removes legacy JS implementation. |
| providers/summary/licensee.d.ts | Removes legacy generated typings. |
| providers/summary/index.ts | Switches summary registry to concrete TS exports + updated types. |
| providers/summary/index.js | Removes legacy JS registry. |
| providers/summary/fossology.ts | New TS implementation of FOSSology summarizer. |
| providers/summary/fossology.js | Removes legacy JS implementation. |
| providers/summary/fossology.d.ts | Removes legacy generated typings. |
| providers/summary/clearlydefined.ts | Refactors ClearlyDefined summarizer types into TS interfaces/classes. |
| providers/summary/clearlydefined.d.ts | Removes legacy generated typings. |
| providers/summary/cdsource.ts | New TS implementation of CdSource summarizer. |
| providers/summary/cdsource.js | Removes legacy JS implementation. |
| providers/summary/cdsource.d.ts | Removes legacy generated typings. |
| providers/index.ts | Converts central provider registry to TS and instantiates the providers object. |
| providers/index.js | Removes legacy JS provider registry. |
| business/summarizer.js | Updates runtime import to providers/summary/index.ts. |
| bin/config.js | Updates runtime import to providers/index.ts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (6)
providers/summary/scancode.ts:149
export defaultallowsoptionsto be omitted, butScanCodeSummarizer's constructor requires a non-optionalSummarizerOptions. This makes the factory call type-unsafe understrictNullChecksand also allowsthis.optionsto becomeundefinedat runtime (tests callSummarizer()with no args). Fix by making the constructor parameter optional/defaulting to{}or by defaultingoptionsin the factory before constructing the class.
providers/summary/clearlydefined.ts:760- The default export passes
options?: SummarizerOptionsinto a constructor that requiresoptions: SummarizerOptions, which is not type-safe understrictNullChecksand will fail compilation. Make the constructor acceptoptions?: SummarizerOptions(and handleundefined) or defaultoptionsin the factory (e.g.,options ?? {}).
providers/summary/clearlydefined.ts:690 - Inside the
if (registryUrl)block, the code later dereferencesresult.described.sourceLocationwithout first ensuringresult.describedexists. Sincedescribedis optional inSummaryResult, this fails TypeScript checking and can throw at runtime. Use optional chaining (result.described?.sourceLocation) or initializedescribedbefore this block (and reflect that in the type).
This issue also appears on line 713 of the same file.
providers/summary/clearlydefined.ts:700
registryData.find(...)can returnundefined, but the code immediately accesses.Path. This is a TypeScript error understrictNullChecksand will throw at runtime if the expected architecture entry is missing. Capture thefindresult, validate it, and either return/throw or fall back to a safe default before building the URL.
This issue also appears on line 717 of the same file.
providers/summary/clearlydefined.ts:716
result.described.sourceLocation = ...assigns through an optional property (described?: ...) without ensuringresult.describedis initialized. This will fail TypeScript checking and can throw at runtime. Initializeresult.described(e.g., viaresult.described ||= {}) before assignment, or change theSummaryResulttype sodescribedis always present when these helpers run.
providers/summary/clearlydefined.ts:719registryData.find(...)may returnundefined, but.Pathis accessed unconditionally when building the Debian source download URL. This is astrictNullCheckstype error and will throw at runtime if no entry matches.orig.tar.. Guard thefindresult and handle the missing case (return/throw/fallback) before constructing the URL.
- Files reviewed: 29/37 changed files
- Comments generated: 1
There was a problem hiding this comment.
Pull request overview
This PR continues the TypeScript migration by converting the providers/summary/ module set (including ScanCode legacy/new summarizers) and the central providers/index registry to .ts, and updates consumers/tests to import the new .ts entrypoints (removing the prior .js + .d.ts pairs).
Changes:
- Convert summary providers (ClearlyDefined, FOSSology, Licensee, REUSE, CdSource, ScanCode + sub-summarizers) to TypeScript and update the summary provider registry.
- Convert
providers/indexto TypeScript and keep the provider registry as a typed runtime object. - Update tests and consumers (
business/,bin/) to import.tsmodules directly (Node 24 ESM + type stripping).
Show a summary per file
| File | Description |
|---|---|
| test/summary/scancode.ts | Update imports to .ts ScanCode summarizers. |
| test/summary/reuse.ts | Update import to .ts REUSE summarizer. |
| test/summary/licensee.ts | Update import to .ts Licensee summarizer. |
| test/summary/fossology.ts | Update import to .ts FOSSology summarizer. |
| test/summary/clearlydefinedTests.ts | Update import to .ts ClearlyDefined summarizer. |
| test/summary/clearlyDefined.ts | Update import to .ts ClearlyDefined summarizer. |
| test/providers/summary/scancode/new-summarizer.mts | Update import to .ts ScanCode summarizer. |
| test/providers/summary/scancode/legacy-summarizer.mts | Update import to .ts ScanCode summarizer. |
| test/providers/summary/fossology.mts | Update import to .ts FOSSology summarizer. |
| providers/summary/scancode/new-summarizer.ts | Add TypeScript implementation for new ScanCode summarizer. |
| providers/summary/scancode/legacy-summarizer.ts | Add TypeScript implementation for legacy ScanCode summarizer. |
| providers/summary/scancode.ts | Convert ScanCode delegator to TypeScript and route by ScanCode version. |
| providers/summary/reuse.ts | Convert REUSE summarizer to TypeScript. |
| providers/summary/licensee.ts | Convert Licensee summarizer to TypeScript. |
| providers/summary/fossology.ts | Convert FOSSology summarizer to TypeScript. |
| providers/summary/clearlydefined.ts | Convert ClearlyDefined summarizer to TypeScript and add explicit types. |
| providers/summary/cdsource.ts | Convert CdSource summarizer to TypeScript. |
| providers/summary/index.ts | Convert summary provider registry to a typed runtime export. |
| providers/index.ts | Convert central provider registry to TypeScript with typed structure. |
| business/summarizer.js | Update summary provider registry import to .ts. |
| bin/config.js | Update providers registry import to .ts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (6)
providers/summary/scancode.ts:150
ScanCodeSummarizer's constructor requiresoptions: SummarizerOptions, but the default export factory acceptsoptions?: SummarizerOptionsand forwards it directly. WithstrictNullChecks,new ScanCodeSummarizer(undefined, ...)is a type error and can happen becauseSummarizerFactoryis defined as(options?: SummarizerOptions) => T. Consider defaultingoptionsto{}in the constructor or factory, or widening the constructor param tooptions?: SummarizerOptionswith an internal default.
providers/summary/clearlydefined.ts:206ClearlyDescribedSummarizer's constructor requiresoptions: SummarizerOptions, but the default export factory acceptsoptions?: SummarizerOptionsand passes it through. This conflicts withSummarizerFactoryallowingundefinedoptions and will failstrictNullChecks. Defaultoptionsto{}(constructor or factory) or widen the constructor parameter to acceptundefinedwith an internal default.
providers/summary/clearlydefined.ts:700registryData.find(...)can returnundefined, but the code immediately dereferences.Path, which will throw at runtime if the expected architecture entry is missing (or ifcoordinates.revisiondoesn’t contain an underscore). Capture thefindresult and handle the not-found case before building the download URL.
This issue also appears on line 717 of the same file.
providers/summary/clearlydefined.ts:721
- Same issue as
addDebData:registryData.find(...)may returnundefined, but.Pathis dereferenced unconditionally. Add a guard/early return (or a clearer error) when no.orig.tar.entry is present to avoid a runtime crash.
providers/summary/clearlydefined.ts:749 addGoDatasetsdescribed.releaseDatetwice in a row with the same value. This is redundant and makes the method harder to maintain; remove the duplicate call.
providers/summary/clearlydefined.ts:636addPyPiDatareadsdata['declaredLicense'], butClearlyDefinedHarvestedDatadoesn’t declare adeclaredLicensefield (onlydeclaredLicenses). This bypasses type checking and makes it easy to break the contract accidentally. Consider addingdeclaredLicense?: stringto the interface (if it’s part of the harvested shape) and accessing it as a normal property (or via a typedget).
- Files reviewed: 29/37 changed files
- Comments generated: 0 new
There was a problem hiding this comment.
Suggestion 1 — All summarizer classes (FOSSologySummarizer, LicenseeSummarizer, ReuseSummarizer, ScanCodeSummarizer, ClearlyDescribedSummarizer, CdSourceSummarizer) should explicitly declare implements BaseSummarizer to make the contract enforcement explicit and catch any drift if BaseSummarizer changes.
Suggestion 2 — Consider making BaseSummarizer generic to tighten the contract:
export interface BaseSummarizer<T = unknown> {
summarize(coordinates: EntityCoordinates, data: T): SummaryResult
}Each summarizer class would then declare implements BaseSummarizer<FossologyHarvestedData> etc., giving both input and output type safety at the base interface level.
| * @param {SummarizerOptions} options - Configuration options for the summarizer | ||
| */ | ||
| constructor(options) { | ||
| export class ClearlyDescribedSummarizer { |
There was a problem hiding this comment.
Implements BaseSummarizer?
4ecc58a to
ea9167c
Compare
a2db100 to
c9a28cc
Compare
c9a28cc to
1f57cdf
Compare
ea9167c to
124002b
Compare
1f57cdf to
48cf9e9
Compare
124002b to
5ca77d0
Compare
5ca77d0 to
3147389
Compare
f008170 to
0f948e0
Compare
Merge 10 files:
providers/summary/(9 files) +providers/index.ts(registry).Review commit-by-commit. Stacked on #1549.