Good night everybody, I’m a newbie on TS and I hav...
# help
t
Good night everybody, I’m a newbie on TS and I have some questions but I wasn’t sure where to post this so I’m going for it in this channel. I’m trying to re-play the guide but TS driven now, that said I’m facing a few random issues that I’ve been able to figure out but this one. So basically this is how my ApiStack looks like:
Copy code
constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    const { table } = props;
And then I’m getting TS errors b/c
table
is not a “typed” property under the
sst.StackProps
. That said, what would be the solution here? I was betting on create my own type (kinda like my own type but extending from the
sst.StackProps
somehow and also append a
table
property and whatever else need across the guide but idk if that’s how it should be in fact, any recommendation?
r
I don't think there'd be a Table in the props passed to a stack. The stack itself would contain the definition for any resource, including any tables. If it needs access to a resource from another stack then that can be imported. I haven't tried this but I think you could create your own construct, like an L3 CDK construct in a stack.
f
@Tonny (sstNerd) 2 solutions: 1. Extend the
StackProps
with the
table
prop. An example here https://docs.serverless-stack.com/constructs/Api#sharing-an-api-across-stacks 2. Pass in the
table
directly instead of wrapping it in
props
Copy code
constructor(scope: <http://sst.App|sst.App>, id: string, table: sst.Table) {
Let me know if this makes sense.
r
That's neat
t
awesome, @Frank solution #1 (creating an interface) made the trick, tyvm!