I am trying to access my region per the docs here:...
# sst
m
I am trying to access my region per the docs here: https://docs.serverless-stack.com/installation#project-config But I am running into this error Property 'region' does not exist on type 'IConstruct'. 23 REGION: this.node.root.region
j
That's weird. Can you post a code snippet where you are looking up the region?
m
Copy code
// MyStack.ts
export default class MyStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);
    
    const region = this.node.root.region
  ]
}
j
That seems right to me, @Frank any ideas?
m
Same error for all three:
Copy code
this.node.root.stage;
this.node.root.region;
this.node.root.name;
f
@Mike McCall hmm.. lemme give it a try..
m
thanks
f
Yeah it’s an issue on our side.. a typescript related issue
For now, just mark it as expected error
Copy code
// @ts-expect-error Working on a fix
const region = this.node.root.region;
I’m putting in a fix
m
Awesome. Thanks!
f
@Mike McCall turns out I didn’t need to fix anything. The better to retrieve region inside a stack is just:
Copy code
class MyStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    const region = scope.region;
  }
}
m
ahh ha. nice.
f
Nice catch!