Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Accept numbers and booleans in `withEnvironment`

オープン
#1,543 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, node.js, typescript
領域
testing, tooling

調査の方向性

Read packages/testcontainers/src/types.ts and trace how Environment is consumed by the two withEnvironment methods and exec's env option. Check how subclasses access the protected environment field, then review the related issue #1519 because both changes rewrite withEnvironment. Done means accepting string, number, boolean, and undefined values while stored environment values remain strings and undefined keys are skipped.

索引モデルが issue の本文から書いたものです。

説明

enhancement minor

What happens

Environment is { [key: string]: string }, so every non-string value has to be converted at the call site:

.withEnvironment({
  PORT: String(port),
  MAX_CONNECTIONS: maxConnections.toString(),
  DEBUG: "true",
})

Optional values need a conditional spread to avoid passing undefined:

.withEnvironment({ ...(token ? { TOKEN: token } : {}) })

The same type is used by DockerComposeEnvironment.withEnvironment and by exec's env option.

Expected

withEnvironment accepts string | number | boolean values and converts them, and skips keys whose value is undefined:

.withEnvironment({ PORT: port, DEBUG: true, TOKEN: token })

Where

  • Environment in packages/testcontainers/src/types.ts
  • withEnvironment in packages/testcontainers/src/generic-container/generic-container.ts
  • withEnvironment in packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts

Notes

  • Widening the accepted type is compatible for callers. Subclasses that read the protected environment field should keep seeing strings.
  • Related: #1519 (duplicate entries when a key is set twice).

Dependencies

  • Stack on #1519: both rewrite withEnvironment.
主要言語
TypeScript
スター
2.6k
フォーク
277
平均マージ
1日 53分
マージ済み PR(30日)
58

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testcontainers/testcontainers-node のほかの issue

testcontainers/testcontainers-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。