interface User { isAdministrator ( ) : boolean ; notify ( ) : void ; doNotDisturb ? ( ) : boolean ; } function sudo ( ) { console . log ( "exec sudu!" ) ; } function doAdminThingB ( user ) { if ( user . isAdministrator ( ) ) { sudo ( ) ; } else { throw new Error ( "User is not an admin" ) ; } } function doAdminThingC ( user ) { if ( ! ! user . isAdministrator ) { sudo ( ) ; } else { throw new Error ( "User is not an admin" ) ; } } function doAdminThingD ( user ) { if ( user . notify ) { user . notify ( ) ; } if ( user . doNotDisturb ) { sudo ( ) ; } } export { } ;