Repository navigation
code not working by ts-node #2075
Replies: 1 comment
|
Your example works when TypeScript treats the file as a script: the top-level Use an explicit global augmentation so the intent is clear in a module: export {};
declare global {
interface String {
stop(): string;
}
}
String.prototype.stop = function () {
return this.toLowerCase();
};
console.log('Hi'.stop());This printed Without the actual error/config I cannot say that this is your exact cause, but this removes the script/module ambiguity. TypeScript's global augmentation documentation. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
when i use these commands
code works
but when i use
it not works why
MyCode
All reactions