Skip to content

Adding Type Safety to __ENV Variables #42

@Nathan-Bernardo

Description

@Nathan-Bernardo

Hi guys, I added Typescript into my k6 scripts and I'm finding it difficult to extend the __ENV type. There are some __ENV variables I defined to be a number, but Typescript will define the value as a string rather than a number due to this type definition

// global.d.ts
declare global {
    const __ENV: { [name: string]: string };
}

Is there a way for me to extend the __ENV type definition? One thing I tried was defining my own global.d.ts file with the following:

declare global {
    namespace __ENV {
        const VUS: number
    }
}

but that didn't work.

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