Skip to content

process type missing #30963

@KnorpelSenf

Description

@KnorpelSenf

Version: Deno 2.5.4

The value of globalThis.process exists at runtime but it does not pass type checking. The same is true for the process global.

Repro

$ # Create a source file that uses globalThis.process
$ echo 'console.log(globalThis.process.argv, process.argv);' > main.ts
$ 
$ # It runs just fine
$ deno main.ts 
[ [Getter], [Getter] ] [ [Getter], [Getter] ]
$ 
$ # However, it does not type-check:
$ deno check main.ts 
Check file:///tmp/repro/main.ts
TS7017 [ERROR]: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
console.log(globalThis.process.argv, process.argv);
                       ~~~~~~~
    at file:///tmp/repro/main.ts:1:24

TS2580 [ERROR]: Cannot find name 'process'.
console.log(globalThis.process.argv, process.argv);
                                     ~~~~~~~
    at file:///tmp/repro/main.ts:1:38

Found 2 errors.

error: Type checking failed.

$ # When we add an unused import of `node:process`, it is fixed:
$ echo 'import _ from "node:process"' >> main.ts 
$ deno check main.ts 
Check file:///tmp/repro/main.ts
$ 

It seems like the types are only available when node:process is imported, but the runtime values are available always.

Workaround

Add the following line to the source file.

import process from "node:process";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions