Declare option fields as optional instead of wrapping the types in `Partial`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, node.js, typescript
Research direction
Read the option declarations and method signatures in packages/testcontainers/src/types.ts, packages/testcontainers/src/compose-runtime/clients/compose/types.ts, and packages/testcontainers/src/testcontainers.ts. Also compare the public and client ExecOptions types, including the client’s log field. Done means option fields document their defaults as optional, methods accept those types directly, and the affected callers and types remain consistent.
Written by the indexing model from the issue text.
Description
What happens
Option types are declared with every field required, and each method then accepts Partial<...> and fills in defaults:
StopOptionsinstop(options?: Partial<StopOptions>)RestartOptionsinrestart(options?: Partial<RestartOptions>)ExecOptionsinexec(command, opts?: Partial<ExecOptions>)ComposeDownOptionsindown(options?: Partial<ComposeDownOptions>)
The exported type does not describe what a caller may pass, and a helper typed as StopOptions has to supply every field. The defaults (timeout: 0, remove, removeVolumes: true) are not visible in the type or in JSDoc.
There are also two ExecOptions types: the public one in types.ts and the container client's one in container-runtime/clients/container/types.ts, which adds log.
Expected
Option types declare optional fields as optional, with the default documented on each field, and methods accept the type directly.
Where
packages/testcontainers/src/test-container.tspackages/testcontainers/src/types.tspackages/testcontainers/src/container-runtime/clients/compose/types.ts
Notes
- Loosening the field types is compatible for callers. Code that reads a
StopOptionsvalue and relies on the fields being required would need a change.
Dependencies
- Nothing blocks this. It can start now.
- Dominant language
- TypeScript
- Stars
- 2.6k
- Forks
- 274
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 44
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testcontainers/testcontainers-node
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
testcontainers/testcontainers-node#1539 ·
Maintainers usually reply within 1 day
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testcontainers/testcontainers-node#1533 ·
Maintainers usually reply within 1 day
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
testcontainers/testcontainers-node#1529 ·
Maintainers usually reply within 1 day
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-node#1528 ·
Maintainers usually reply within 1 day
-
bug patch
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
testcontainers/testcontainers-node#1526 ·
Maintainers usually reply within 1 day
All issues in testcontainers/testcontainers-node
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
homarr-labs/homarr#7191 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AvaProtocol/ava-sdk-js#276 ·
Maintainers usually reply within 1 day
-
useFragment does not require `variables` when the fragment's variables type has required fieldsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apollographql/apollo-client#13493 ·
Maintainers usually reply within 1 day