Is it possible to have a class with constant strings that get compiled as inline code in typescript? -


what looking exact same functionality const enum in typescript strings. doesn't have actual type (although bonus), looking way have large list of const strings compiled js. reason have large list of "magic strings" replace bit less error prone, don't want overhead of having huge list of types aren't used on every page.

typescript:

const enum foo {     bara = "bara";     barb = "barb"; }  class test {     myfunction = () => {         var = foo.bara;     } } 

compiled javascript:

var test = (function () {     function test() {         this.myfunction = function () {             var = "bara";         };     }     return test; })(); 

is possible have class constant strings compiled inline code in typescript

not @ moment.

that said use object literal , let typescript infer correct type :

var foo = {     bar: 'bar',     bas: 'bas' }   var = foo.bar; // okay  var somethingelse = foo.baz; // error 

ofcourse don't inlining you remove magic nature of these strings.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -