Skip to content

fix(types): allow undefined values in populate output - #1074

Merged
motdotla merged 1 commit into
motdotla:masterfrom
himanshu748:codex/fix-dotenv-populate-undefined-20261011
Oct 14, 2026
Merged

motdotla merged 1 commit into
motdotla:masterfrom
himanshu748:codex/fix-dotenv-populate-undefined-20261011

Conversation

@himanshu748

Copy link
Copy Markdown
Contributor

populate() accepts undefined input values and preserves them in its result, but DotenvPopulateOutput currently declares every value as string.
Change the output index signature to string | undefined. Add a strict TypeScript regression that rejects assigning an undefined-capable populated value to a required string, plus a runtime test documenting the existing behavior for empty and populated targets with override: true.
This is a declaration correction; the runtime implementation is unchanged. Consumers using strict null checks may need to narrow a populated value before treating it as a string.
Validation recorded in the 12 October 2026 handoff on Linux, Node 24.19.0 and npm 11.9.0:

  • The new type test fails against the original declaration with TS2578 and passes with the change.
  • The runtime control passes against the original implementation, confirming it already preserves undefined values.
  • npm test: build, Standard lint, strict TypeScript checks, and TAP passed; 1,203 passed and 1 skipped.
  • npm run test:perf: passed; fast/classic ratio 2.21x for Buffer input and 2.39x for string input, above the 1.5x gate.
    The Windows executable/batch-shim case was skipped on Linux. The full Ubuntu/Windows and Node 20/22/24/26 matrix was not run.
    AI assistance: Codex assisted with this contribution and regression validation.

@himanshu748
himanshu748 marked this pull request as ready for review October 12, 2026 08:12
@motdotla

Copy link
Copy Markdown
Owner

appreciate this but this is ai thinking... this is just not a real edge case in the history of .env files. no one uses proto as a key name. not worth the added complexity to support such a non-existent edge case.

@motdotla motdotla closed this Oct 14, 2026
@motdotla motdotla reopened this Oct 14, 2026
@motdotla

Copy link
Copy Markdown
Owner

oops that comment above was meant for a different PR. reviewing this one now.

@himanshu748

Copy link
Copy Markdown
Contributor Author

oops that comment above was meant for a different PR. reviewing this one now.

Lol🥲will wait.

@motdotla
motdotla merged commit 53405b0 into motdotla:master Oct 14, 2026
16 checks passed
@motdotla

Copy link
Copy Markdown
Owner

merged. thanks! will go out shortly as x.x.8

renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 17, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 18.0.7 | 18.0.8 |


## [v18.0.8](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

##### Changed

- Fast parser should strip appended extra quotes ([#1073](motdotla/dotenv#1073))
- Type detail improvement ([#1074](motdotla/dotenv#1074))
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.

2 participants