Hello, I'm encountering an issue when passing a pr...
# help
k
Hello, I'm encountering an issue when passing a prop to a stack in Typescript. The code below comes from the vanilla JS guide. In TS, I get the following error:
Copy code
Argument of type '{ bucket: sst.Bucket; }' is not assignable to parameter of type 'StackProps'.
  Object literal may only specify known properties, and 'bucket' does not exist in type 'StackProps'.
I understand the error but how do I get around it?
Tried this but failed but need to properly destructure props
a
how have you defined the bucket in the storageStack?
k
Hello, the first image shows my
stacks/StorageStack.ts
and the second image shows no issues pulling out the bucket variable from
stacks/index.ts
b
Not sure if you figured this out yet but the error is popping up because there’s no field called
bucket
in
StackProps
which is the 3rd argument your stack is likely expecting. if it’s set up similarly to the StorageStack you screenshot above. This is what the
StackProps
looks like: https://docs.serverless-stack.com/constructs/Stack#stackprops It’s quite likely that you’ve not used the correct type in you constructors for your other two stacks.
k
Yep, this is ok now. My solution above worked with minor tweaks. I had issues trying to destructure the
bucket
from props because it could be undefined. Will mark the correct answer with a check for anyone who might encounter the issue