Issue
I want to define a decorator to mark properties for specific ESLint rules to be applied at dev time. After compilation there should be no sign of that decorator any more.
function notExistingAfterTSCompilation() {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
// Returning the original descriptor without making any changes
return descriptor;
};
}
class ExampleClass {
@notExistingAfterTSCompilation()
method() {}
}
should compile to only:
class ExampleClass {
method() { }
}
It might be smelly to try that at all. Any other suggestions?
ChatGpt suggested some jsdoc like comments:
class ExampleClass {
/**
* @assertions
*/
markedProperty: string;
constructor() {
this.markedProperty = "Hello";
}
}
Solution
ChatGpt suggested some jsdoc like comments could solve this problem, this is confirmed by other users in the comments section:
class ExampleClass {
/**
* @assertions
*/
markedProperty: string;
constructor() {
this.markedProperty = "Hello";
}
}
Answered By - Andre Elrico
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.