File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ export function defineSecret(name: string): SecretParam {
130
130
* @param options Configuration options for the parameter.
131
131
* @returns A parameter with a `string` return type for `.value`.
132
132
*/
133
- export function defineString ( name : string , options : ParamOptions < string > = { } ) : StringParam {
133
+ export function defineString < T extends string > ( name : string , options : ParamOptions < T > = { } ) : StringParam < T > {
134
134
const param = new StringParam ( name , options ) ;
135
135
registerParam ( param ) ;
136
136
return param ;
Original file line number Diff line number Diff line change @@ -293,12 +293,18 @@ export interface SelectOptions<T = unknown> {
293
293
value : T ;
294
294
}
295
295
296
+ /**
297
+ * This can be removed once typescript is upgraded to v5.4+
298
+ * @internal
299
+ */
300
+ type NoInfer < T > = [ T ] [ T extends any ? 0 : never ] ;
301
+
296
302
/** The wire representation of a parameter when it's sent to the CLI. A superset of `ParamOptions`. */
297
303
export type ParamSpec < T extends string | number | boolean | string [ ] > = {
298
304
/** The name of the parameter which will be stored in .env files. Use UPPERCASE. */
299
305
name : string ;
300
306
/** An optional default value to be used while prompting for input. Can be a literal or another parametrized expression. */
301
- default ?: T | Expression < T > ;
307
+ default ?: NoInfer < T > | Expression < NoInfer < T > > ;
302
308
/** An optional human-readable string to be used as a replacement for the parameter's name when prompting. */
303
309
label ?: string ;
304
310
/** An optional long-form description of the parameter to be displayed while prompting. */
@@ -468,10 +474,10 @@ export class SecretParam {
468
474
* A parametrized value of String type that will be read from .env files
469
475
* if present, or prompted for by the CLI if missing.
470
476
*/
471
- export class StringParam extends Param < string > {
477
+ export class StringParam < T extends string = string > extends Param < T > {
472
478
/** @internal */
473
- runtimeValue ( ) : string {
474
- return process . env [ this . name ] || "" ;
479
+ runtimeValue ( ) : T {
480
+ return process . env [ this . name ] as T ;
475
481
}
476
482
}
477
483
You can’t perform that action at this time.
0 commit comments