diff --git a/src/params/index.ts b/src/params/index.ts index fadd36b54..c8b7c2b96 100644 --- a/src/params/index.ts +++ b/src/params/index.ts @@ -130,7 +130,7 @@ export function defineSecret(name: string): SecretParam { * @param options Configuration options for the parameter. * @returns A parameter with a `string` return type for `.value`. */ -export function defineString(name: string, options: ParamOptions = {}): StringParam { +export function defineString(name: string, options: ParamOptions = {}): StringParam { const param = new StringParam(name, options); registerParam(param); return param; diff --git a/src/params/types.ts b/src/params/types.ts index 0d0413413..9eb557418 100644 --- a/src/params/types.ts +++ b/src/params/types.ts @@ -293,12 +293,18 @@ export interface SelectOptions { value: T; } +/** + * This can be removed once typescript is upgraded to v5.4+ + * @internal + */ +type NoInfer = [T][T extends any ? 0 : never]; + /** The wire representation of a parameter when it's sent to the CLI. A superset of `ParamOptions`. */ export type ParamSpec = { /** The name of the parameter which will be stored in .env files. Use UPPERCASE. */ name: string; /** An optional default value to be used while prompting for input. Can be a literal or another parametrized expression. */ - default?: T | Expression; + default?: NoInfer | Expression>; /** An optional human-readable string to be used as a replacement for the parameter's name when prompting. */ label?: string; /** An optional long-form description of the parameter to be displayed while prompting. */ @@ -468,10 +474,10 @@ export class SecretParam { * A parametrized value of String type that will be read from .env files * if present, or prompted for by the CLI if missing. */ -export class StringParam extends Param { +export class StringParam extends Param { /** @internal */ - runtimeValue(): string { - return process.env[this.name] || ""; + runtimeValue(): T { + return process.env[this.name] as T; } }