diff --git a/src/environment.ts b/src/environment.ts index 9f6107025..bbb29aab1 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -281,8 +281,8 @@ export function getOptionalEnvVar(paramName: string): string | undefined { * in tests, while clearly signalling in regular code that the consumer of the `ReadOnlyEnv` instance * will only read from it. */ -export class ReadOnlyEnv { - constructor(protected readonly vars: Record) {} +export class ReadOnlyEnv { + constructor(protected readonly vars: Record) {} /** Clones the object while detaching the underlying environment from the original. */ public clone(): this { @@ -290,7 +290,7 @@ export class ReadOnlyEnv { } /** Gets a copy of the underlying environment. */ - public get(): Record { + public get(): Record { return { ...this.vars }; } @@ -305,7 +305,7 @@ export class ReadOnlyEnv { } /** Gets the entries of the underlying `ProcessEnv`. */ - public entries(): Array<[string, T]> { + public entries(): Array<[string, string | undefined]> { return Object.entries(this.vars); } @@ -335,19 +335,17 @@ export class ReadOnlyEnv { * Use `ReadOnlyEnv` instead if you only plan to read from the environment. * This type allows writing to the environment. */ -export class Env< - T extends string | undefined = string | undefined, -> extends ReadOnlyEnv { +export class Env extends ReadOnlyEnv { private changed: boolean = false; /** Sets an environment variable. */ - public set(name: string, value: T): void { + public set(name: string, value: string): void { this.vars[name] = value; this.changed = true; } /** Sets all environment variables given by `vars`. */ - public setAll(vars: Record): void { + public setAll(vars: Record): void { for (const [key, val] of Object.entries(vars)) { this.set(key, val); } @@ -361,7 +359,7 @@ export class Env< * @param name The name of the environment variable to set and export. * @param val The value to set and export for the environment variable. */ - public export(name: string, val: T): void { + public export(name: string, val: string): void { // Setting the environment variable for this instance is always OK, including // in tests, since we use fresh `Env` instances whenever needed. This allows // tests to pass that rely on that part of the `core.exportVariable` behaviour.