Why can't TypeScript modules implement or adhere to an interface? Can I get around this? -


it seems useful in typescript require module implement interface. there particular reason why they've chosen not implement ability?

i can't think of reason why undesirable allow module implement interface, if is, there other way require module provide set of properties / methods?

you can force compile error if module doesn't adhere interface (technically non-zero runtime overhead, unlikely matter):

interface foo {     bar(): number; }  module mod {     export function bar(): number {         return 0;     } } var mod_is_foo: foo = mod; // errors if change 'number' 'string' above 

as why can't module mod implements foo? all features start @ minus 100.

edit add -- here other (somewhat wacky) things write in lieu of var statement above if wanted avoid creating new top-level var:

<foo>mod; // shortest, fastest? <foo>undefined === mod; // clearest non-var version? 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -