Typescript: Prevent Use Of ".name" To Get Function/class Name
is there an easy way (maybe tslint rule) to prevent us from using MyClass.name, or myFunction.name? We're trying to make sure no Dev end up using this, as the minification process
Solution 1:
Untested, so mileage may vary from 0 to 100, but you can try the following. Inside a global/ambient ts file write:
declareglobal {
interfaceFunction {
/** @deprecated Don't use this, think about the children!*/readonlyname: string;
}
}
Then set in your tslint config:
"rules":{"deprecation":true}
Perhaps this will warn the developer with a deprecation notice, but there is also a possibility it's ignored, because the lib typings do not have this comment
Post a Comment for "Typescript: Prevent Use Of ".name" To Get Function/class Name"