I'm currently trying to enhance the String class in TypeScript 2.5 by adding a static method, which will be compiled to ES5.
Here's what I have in StringExtensions.d.ts:
declare interface StringConstructor {
isNullOrEmpty(value: string | null): boolean;
}
And in StringExtensions.tsx:
String.isNullOrEmpty = function(value: string | null) {
return value == null || value == "";
}
Even though I use it like this:
String.isNullOrEmpty("my string");
I encounter an error in Chrome stating that "String.isNullOrEmpty" is not recognized as a function. Surprisingly, the code compiles without any issues when using "target": "es5" in tsconfig.json. Any clues on why this might be happening?