Skip to content

Convert providers/summary/ and providers/index to TypeScript#1550

Merged
JamieMagee merged 9 commits intomasterfrom
ts-providers/summary
Apr 13, 2026
Merged

Convert providers/summary/ and providers/index to TypeScript#1550
JamieMagee merged 9 commits intomasterfrom
ts-providers/summary

Conversation

@JamieMagee
Copy link
Copy Markdown
Contributor

@JamieMagee JamieMagee commented Apr 11, 2026

Merge 10 files: providers/summary/ (9 files) + providers/index.ts (registry).

Review commit-by-commit. Stacked on #1549.

@JamieMagee JamieMagee changed the title ts providers/summary Convert providers/summary/ and providers/index to TypeScript Apr 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .ts implementations (ScanCode legacy/new, FOSSology, Licensee, REUSE, CdSource; plus updated ClearlyDefined).
  • Update providers/summary/index.ts to export a typed runtime summaryProviders object, and update callers/tests to import .ts.
  • Convert providers/index to a typed TS provider registry and update bin/config.js to 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?, but ClearlyDescribedSummarizer's constructor requires a non-optional SummarizerOptions, which will fail tsc when callers omit options. Make the constructor param optional/defaulted, or coalesce options ?? {} in the factory.
    providers/summary/scancode.ts:132
  • The factory signature allows options to be omitted, but ScanCodeSummarizer's constructor requires a non-optional SummarizerOptions. This will fail type-checking when the summarizer is constructed without options (which current tests do). Consider defaulting options in the constructor or factory.
    providers/summary/scancode/new-summarizer.ts:193
  • licenseExpressions is typed as Set<string>, but match.spdx_license_expression is optional. Adding it without checking will fail tsc and can propagate undefined into license joining. Guard on match.spdx_license_expression (and/or narrow the match type) before add.
  _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

  • addArrayToSet is given a Set<string> but the value extractor can return undefined (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

  • licenses is used with joinExpressions (expects Set<string>), but the mapped values come from optional fields and _createExpressionFromLicense() can return null. This will fail tsc. Narrow/filter to string values (e.g., use a type guard) and type the set as Set<string> before calling joinExpressions.
        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.find can return undefined, so accessing .Path directly is a TypeScript error under strictNullChecks and 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 return undefined, so .Path access will fail tsc and 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

@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from 032efd3 to 4ddc6a9 Compare April 11, 2026 21:36
@JamieMagee JamieMagee force-pushed the ts-providers/curation branch 2 times, most recently from 1d826cf to 1b2c208 Compare April 11, 2026 21:52
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch 2 times, most recently from 016856f to 67642ad Compare April 11, 2026 21:53
@JamieMagee JamieMagee force-pushed the ts-providers/curation branch from 1b2c208 to 9619521 Compare April 11, 2026 21:53
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from 67642ad to ce3272c Compare April 11, 2026 22:01
@JamieMagee JamieMagee force-pushed the ts-providers/curation branch from 9619521 to 2751711 Compare April 11, 2026 22:01
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from ce3272c to c54bc5f Compare April 11, 2026 23:01
@JamieMagee JamieMagee requested a review from Copilot April 12, 2026 00:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts pairs in providers/summary/ with .ts implementations (and updated summary provider registry wiring).
  • Converted providers/index registry to a typed providers/index.ts export and updated consumers to import it.
  • Updated tests and service code to import summarizers from .ts entrypoints.
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-undefined options/logger into a constructor that currently requires options: SummarizerOptions and logger: Logger. This will not type-check under strictNullChecks. Make the constructor accept optional values (and/or default options to {}) and align the options property 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?: Logger is not assignable to Logger at 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:702
  • registryData.find(...) can return undefined, 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., unexpected Architecture). Add a guard or fallback when find returns undefined before building the download URL.

This issue also appears on line 715 of the same file.
providers/summary/clearlydefined.ts:721

  • registryData.find(...) can return undefined, but .Path is 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?: SummarizerOptions into new ClearlyDescribedSummarizer(options), but the constructor currently requires options: SummarizerOptions. This won’t type-check under strictNullChecks. 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
  • ScanCodeNewSummarizer uses match.score >= 80 where score is optional, which won’t type-check. Add an explicit guard for score being 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 providers object now includes harvest.throttler.filter, but the Providers/HarvestProviders type definitions in this file don’t declare a throttler property. This makes const providers: Providers = { ... } fail type-checking (and the registry type is missing a supported provider group). Add throttler to 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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts pairs.
  • Update providers/summary/index.ts and providers/index.ts to be concrete registries (instead of declaration-only typing / JS objects).
  • Update tests and consuming modules to import .ts modules.
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?: SummarizerOptions but passes it to new ClearlyDescribedSummarizer(options) where the constructor requires SummarizerOptions. 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?: SummarizerOptions and logger?: Logger and forwards them to new ScanCodeSummarizer(options, logger), but the constructor parameters are non-optional. This is a strictNullChecks type error; prefer defaulted (non-optional) factory params or widen constructor param types and default internally.
  • Files reviewed: 29/37 changed files
  • Comments generated: 4

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts artifacts.
  • Rebuild providers/summary/index.ts and providers/index.ts as concrete registries (instead of declared-only typing).
  • Update tests and runtime modules to import *.ts provider 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 default allows options to be omitted, but ScanCodeSummarizer's constructor requires a non-optional SummarizerOptions. This makes the factory call type-unsafe under strictNullChecks and also allows this.options to become undefined at runtime (tests call Summarizer() with no args). Fix by making the constructor parameter optional/defaulting to {} or by defaulting options in the factory before constructing the class.
    providers/summary/clearlydefined.ts:760
  • The default export passes options?: SummarizerOptions into a constructor that requires options: SummarizerOptions, which is not type-safe under strictNullChecks and will fail compilation. Make the constructor accept options?: SummarizerOptions (and handle undefined) or default options in the factory (e.g., options ?? {}).
    providers/summary/clearlydefined.ts:690
  • Inside the if (registryUrl) block, the code later dereferences result.described.sourceLocation without first ensuring result.described exists. Since described is optional in SummaryResult, this fails TypeScript checking and can throw at runtime. Use optional chaining (result.described?.sourceLocation) or initialize described before 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 return undefined, but the code immediately accesses .Path. This is a TypeScript error under strictNullChecks and will throw at runtime if the expected architecture entry is missing. Capture the find result, 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 ensuring result.described is initialized. This will fail TypeScript checking and can throw at runtime. Initialize result.described (e.g., via result.described ||= {}) before assignment, or change the SummaryResult type so described is always present when these helpers run.
    providers/summary/clearlydefined.ts:719
  • registryData.find(...) may return undefined, but .Path is accessed unconditionally when building the Debian source download URL. This is a strictNullChecks type error and will throw at runtime if no entry matches .orig.tar.. Guard the find result and handle the missing case (return/throw/fallback) before constructing the URL.
  • Files reviewed: 29/37 changed files
  • Comments generated: 1

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/index to TypeScript and keep the provider registry as a typed runtime object.
  • Update tests and consumers (business/, bin/) to import .ts modules 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 requires options: SummarizerOptions, but the default export factory accepts options?: SummarizerOptions and forwards it directly. With strictNullChecks, new ScanCodeSummarizer(undefined, ...) is a type error and can happen because SummarizerFactory is defined as (options?: SummarizerOptions) => T. Consider defaulting options to {} in the constructor or factory, or widening the constructor param to options?: SummarizerOptions with an internal default.
    providers/summary/clearlydefined.ts:206
  • ClearlyDescribedSummarizer's constructor requires options: SummarizerOptions, but the default export factory accepts options?: SummarizerOptions and passes it through. This conflicts with SummarizerFactory allowing undefined options and will fail strictNullChecks. Default options to {} (constructor or factory) or widen the constructor parameter to accept undefined with an internal default.
    providers/summary/clearlydefined.ts:700
  • registryData.find(...) can return undefined, but the code immediately dereferences .Path, which will throw at runtime if the expected architecture entry is missing (or if coordinates.revision doesn’t contain an underscore). Capture the find result 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 return undefined, but .Path is 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
  • addGoData sets described.releaseDate twice 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:636
  • addPyPiData reads data['declaredLicense'], but ClearlyDefinedHarvestedData doesn’t declare a declaredLicense field (only declaredLicenses). This bypasses type checking and makes it easy to break the contract accidentally. Consider adding declaredLicense?: string to the interface (if it’s part of the harvested shape) and accessing it as a normal property (or via a typed get).
  • Files reviewed: 29/37 changed files
  • Comments generated: 0 new

Copy link
Copy Markdown
Collaborator

@qtomlinson qtomlinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implements BaseSummarizer?

@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from 4ecc58a to ea9167c Compare April 13, 2026 22:55
@JamieMagee JamieMagee force-pushed the ts-providers/curation branch from a2db100 to c9a28cc Compare April 13, 2026 22:55
@JamieMagee JamieMagee force-pushed the ts-providers/curation branch from c9a28cc to 1f57cdf Compare April 13, 2026 23:03
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from ea9167c to 124002b Compare April 13, 2026 23:03
@JamieMagee JamieMagee force-pushed the ts-providers/curation branch from 1f57cdf to 48cf9e9 Compare April 13, 2026 23:08
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from 124002b to 5ca77d0 Compare April 13, 2026 23:08
Base automatically changed from ts-providers/curation to master April 13, 2026 23:12
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from 5ca77d0 to 3147389 Compare April 13, 2026 23:15
@JamieMagee JamieMagee force-pushed the ts-providers/summary branch from f008170 to 0f948e0 Compare April 13, 2026 23:30
@JamieMagee JamieMagee merged commit 3890a08 into master Apr 13, 2026
4 checks passed
@JamieMagee JamieMagee deleted the ts-providers/summary branch April 13, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants