worried-queen-62794
12/21/2020, 11:43 PMOutput<boolean> | undefined
and a function boolean => string | undefined
I can apply that to get Output<string | undefined> | undefined
. How can lift the inner undefined
out so it just becomes ``Output<string> | undefined` ?little-cartoon-10569
12/21/2020, 11:46 PM!
to the result of the function call?string
and allow it to throw an exception when it previously returned undefined
, that would fix it...| undefined
is a good thing to avoid...worried-queen-62794
12/21/2020, 11:50 PM!
. undefined
is a legitimate value.little-cartoon-10569
12/21/2020, 11:52 PMworried-queen-62794
12/21/2020, 11:54 PMfoo?: Input<string>
. I have a boolean
which when true
I will pass foo: "bar"
and when false
then foo: undefined
. This worked fine until I had to lift the boolean
into an Input<boolean>
and now I can't get it to work.Output
had a filter
method then it would work.little-cartoon-10569
12/21/2020, 11:55 PMworried-queen-62794
12/21/2020, 11:56 PMstring
. It would have to be a string | undefined
as it is an optional value.little-cartoon-10569
12/21/2020, 11:58 PMfoo: variable ?? undefined
?undefined
.foo: variable
worried-queen-62794
12/22/2020, 12:03 AMinterface A {
something: pulumi.Output<boolean>
}
class B {
constructor(anotherThing?: Input<string>) {
// ...
}
}
function bar(bool?: boolean) {
new B(bool ? "This is another thing" : undefined)
}
function foo(a?: Input<boolean>) {
new B(pulumi.output(a).apply(bool => bool ? "This is another thing" : undefined))
}
const a: A = undefined!;
foo(a?.something);
bar
works and looks pretty normal (ok maybe it wouldn't be optional but often it is when there is an args type and there is a default). It doesn't seem like much of a jump to go to foo
.Promise<boolean>
to Promise<string> | undefined
class B {
constructor(anotherThing?: Input<string | undefined>) {
// ...
}
}
In which case I can use !
and lie to the compiler.little-cartoon-10569
12/22/2020, 1:12 AMbar()
function; just pass in the string. And I suppose it's just because it's an MCVE, but pulumi.interpolate
is suitable for the foo()
function.worried-queen-62794
12/22/2020, 2:22 AMboolean
is forever trapped inside the Output
. In Scala it is the same as trying to do Future[Boolean] => Option[Future[String]]
which can't be done (at least not in a pure way). I assume Kotlin is the same.little-cartoon-10569
12/22/2020, 2:27 AM