Skip to content

Incorrect typing of ProcessEnv #68749

@ehmicky

Description

@ehmicky

Link to the code that reproduces this issue

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbwM5gIYHcB2BfOAzKCEOAckwgBMBTALgGMALYAGwoH0xC6qkkSBYAFChIsUpioAPGAMFCUGTAAoSVRhBIAaOAG1Vk1OGZUSAXW0IqmAG41EAUQAaAQQCyABQAy9u-sNhjEmxsAEogA

To Reproduce

import {spawn} from 'node:child_process'
import 'next'

spawn('echo', ['example'], {env: {EXAMPLE: 'example'}})

TypeScript playground

Current vs. Expected behavior

No type error should happen. Instead, the following is printed:

No overload matches this call.
  The last overload gave the following error.
    Property 'NODE_ENV' is missing in type '{ EXAMPLE: string; }' but required in type 'ProcessEnv'.

When import 'next' is commented out, no type error happens (TypeScript playground).

Provide environment information

This is using the TypeScript playground, i.e. is not run on a local machine.

Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

#8379 is a similar issue, but is distinct. Unlike #8379, this issue is not related to Execa and can be reproduced with node:child_process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to types with Next.js.bugIssue was opened via the bug report template.invalid linkThe issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions