Hello, I'm looking for a way to do a conditional o...
# typescript
e
Hello, I'm looking for a way to do a conditional output. Pseudocode below:
Copy code
if (config.createS3Bucket) {
  const s3Bucket = new ...
  export s3BucketName = s3Bucket.name
}
The thing is that typescript wants all `export`'s to be at the top level. What do I do?
p
Copy code
export let s3BucketName: string;
if(){
  s3Bucketname = s3Bucket.name
}
Will get you an undefined in the export when you do not have a bucket, but that is easy to check later on.
e
thanks!
also had to declare resource itself on the top level to be able use it in other places