Following the guide but trying with Typescript, I'...
# sst
a
Following the guide but trying with Typescript, I'm at https://serverless-stack.com/chapters/add-an-api-to-create-a-note.html and getting an error with the
table
value as it does not exist and I'm not sure how to pass or type the value/reference correctly. I haven't yet added any checks for
undefined
and am not certain if
StackProps
is the right value here. How do I let the code know that
table
will exist as a property on
props
with the correct type, and where/how does this value get passed through?
Copy code
export default class ApiStack extends sst.Stack {
  // Public reference to the API
  api;

  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    // Property 'table' does not exist on type 'StackProps | undefined'.ts(2339)
    const { table } = props;

// ...
a
To pass your own variables into stacks, define your own
interface
that extends
sst.StackProps
and add properties, such as
table: sst.Table
.
a
Thanks @Adam Fanello makes sense