Quantcast
Viewing all articles
Browse latest Browse all 5

Answer by Nypan for Extend Basic Types in TypeScript, Error: "_this is not defined..."

I think that this is the same thing that stride was getting at but you simply extend it in javascript (javascript is valid typescript) and then interface the new functionality.

Short example:

String.prototype.myExtension = function () {   return this +" something."};interface String {    myExtension : () => string;}alert("test".myExtension());

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>