Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd be very curious if, in the same way that "TypeScript is a superset of JavaScript", there could be a superset of TypeScript that encouraged one to annotate when they're performing IO operations (reading from/writing to the DOM, the network, workers, storage, etc) and if you consumed a function that had said annotation it would further encourage you to annotate that function as well. Something like:

    function writeStringToLocalStorage(key: string, value: string): void, *localStorage {
      // impl
    }

    function persistUsername(username: string): void {
      // ...
      writeStringToLocalStorage('username', username)
      // ...
    }
^ compiler complains that persistUsername writes to localStorage but does not have the *localStorage IO annotation. While I feel like TypeScript does a great job of working with arguments and return values there's still a whole class of issues that can crop up from things like unexpected DOM manipulation that still would be useful in detecting.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: