Quantcast
Channel: Extend Basic Types in TypeScript, Error: "_this is not defined..." - Stack Overflow
Browsing all 5 articles
Browse latest View live

Answer by Thalles Noce for Extend Basic Types in TypeScript, Error: "_this is...

You need to extend the String interface like this:interface String { stringFormat(...args: string[]): string;}and you need to implement like thismodule Utilities { String.prototype.stringFormat =...

View Article



Answer by QueueHammer for Extend Basic Types in TypeScript, Error: "_this is...

I ended up running into another issue later in the day that made me see what was happening here. From the top, here it is...TypeScript is built on top of JavaScript, so like @Nypan says JavaScript is...

View Article

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

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:...

View Article

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

In exactly similiar case i do it like that:interface String { endsWith(str); startsWith(str);}This is just to satisfy the compiler. You implement the methods exactly like in javascript.Hope that helps.

View Article

Extend Basic Types in TypeScript, Error: "_this is not defined..."

I am trying to rewrite some of my JavaScript code in TypeScript. Some of this code has references to an extension I added to the string object prototype.String.prototype.format = function () { var...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images