Skip to content

Export the types used in public method signatures #1528

Open

Description

@cristianrgreco

What happens

Several types appear in public method signatures but are not exported from packages/testcontainers/src/index.ts, so consumers cannot name them. That makes it awkward to build arguments in a helper, annotate a variable, or write a wrapper.

Type Appears in
BindMount withBindMounts
TmpFs withTmpFs
Ulimits withUlimits
ExtraHost withExtraHosts
ResourcesQuota withResourcesQuota
DirectoryToCopy withCopyDirectoriesToContainer, copyDirectoriesToContainer
ArchiveToCopy withCopyArchivesToContainer
BuildArgs GenericContainerBuilder.withBuildArgs
HttpWaitStrategy return type of Wait.forHttp
CompositeWaitStrategy return type of Wait.forAll
ShellWaitStrategy return type of Wait.forSuccessfulCommand
StartedGenericContainer return type of StartedDockerComposeEnvironment.getContainer
ComposeDownOptions StartedDockerComposeEnvironment.down, StoppedDockerComposeEnvironment.down
ComposeOptions DockerComposeEnvironment.withClientOptions
Reaper return type of getReaper
Ports, HostPortBindings, HealthCheckStatus, NetworkSettings fields of the exported InspectResult

AbstractWaitStrategy is not exported either. A custom wait strategy that is not a StartupCheckStrategy has to implement WaitStrategy directly and re-implement the timeout bookkeeping (withStartupTimeout, isStartupTimeoutSet, getStartupTimeout).

Expected

Every type that appears in an exported signature is exported from index.ts. AGENTS.md already asks for this when a type becomes part of the public API.

Where

packages/testcontainers/src/index.ts.

Notes

  • getContainer could return the StartedTestContainer interface instead of exporting the concrete StartedGenericContainer class.
  • npm run knip does not catch these, because the types are used by other files.
  • A check that fails when an exported signature references an unexported type would stop this recurring.

Dependencies

  • Nothing blocks this. It can start now.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestminorBackward compatible functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions