I am getting a type error on stack reference: `In...
# typescript
g
I am getting a type error on stack reference:
Initializer type Output<any> is not assignable to variable type pulumi.Output<string[]>
Copy code
type DbParams = {
  db: {
    arn: string
  }
}

const db_params: pulumi.Output<DbParams> = SHARED_STACK_REF.requireOutput("dev")
the only way to fix is this is to cast the result
Copy code
const db_params: pulumi.Output<DbParams> = SHARED_STACK_REF.requireOutput("dev") as pulumi.Output<DbParams>
however this is not a problem for simple outputs
Copy code
const vpc_id: pulumi.Output<string> = SHARED_STACK_REF.requireOutput("vpc_id")
am I doing anything wrong here?
l
Generally it's best to provide only primitives as outputs. Casting the Output like that is just masking the problem. Even if the source and destination projects are using the same type at runtime, the output in the stack may be an old version of that type, and you'll be forced to clean up when types change.
g
I agree. In general, I am trying to avoid stack references and prefer lookups because lookups are much faster due to pulumi service being horribly slow