https://pulumi.com logo
Title
s

steep-angle-29984

06/17/2020, 9:19 AM
I can't wrap my head around this, maybe someone can help me out. I want do implement a default value for an optional pulumi.Input where the default value is also an pulumi.Input. This doesn't work:
function getValue(optionalValue: pulumi.Input<number | undefined>, defaultValue: pulumi.Input<number>): pulumi.Input<number> {
    return pulumi.output(optionalValue).apply( v => {
        return v ?? defaultValue
    })
}
Error:(91, 9) TS2322: Type 'Output<Input<number>>' is not assignable to type 'Input<number>'. Type 'OutputInstance<Input<number>>' is not assignable to type 'Input<number>'. Type 'OutputInstance<Input<number>>' is not assignable to type 'OutputInstance<number>'. Type 'Input<number>' is not assignable to type 'number'. Type 'Promise<number>' is not assignable to type 'number'.