javascript - How to extend a primitive type in typescript? -


I want to create an interface like this:

  Show interface {show (): String; } Function doit (s: show) {return 'shown:' + s.show (); }   

Then we can use it with a new class:

  square fu {s: string; Creator (S: String) {this.s = s; } Showing () {Return 'with Foo' '+ + this.s +' ''; }} Console.log (doit (new foo ('hello'));   

I want to do the same for the number s in plain javascript i < Code> number , for example, please satisfy this interface like this:

  number.prototype.show = function () {return '' + this ;}   

But typecript does not allow me to:

  show.ts (18,18): error TS2094: property 'shows' does type The value of 'number' is not present at   

is there any way to do this Simply tell the typewrite by adding it to number :

  Interface number {show (): string;} number. Protopp. Show = function () {return "'+ this;} var foo = 123; foo.show ();   

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -