How to use defined in class file with namespace

From the PHP manual on defining namespaces:

Namespaces are declared using the namespace keyword. A file containing
a namespace must declare the namespace at the top of the file before
any other code – with one exception: the declare keyword.

To fix the issue, simply make sure that your namespace declaration comes before the other code:

namespace JSR;

defined( 'ABSPATH' ) || exit;

class myClass{

}