Conditional selection

Seemed simple but it’s giving me trouble,
I would like to know where I’m wrong

my intention is this
if a selection is present it does one thing
if it is not present, it makes another one

this is what i have

const app = require("photoshop").app;
  if (app.activeDocument.selection.bounds) {
showAlert("test 1.");
    }else {
showAlert("test 2.");
  catch(err) {

Sadly Selection API is still under review. Your code will work but not just in the current version of PS.

For now, you would use batchPlay to read the document property.

Thanks Jarda I think this uxp system is still very immature to be used casually. I hope it will be more usable and intuitive in the future.