0

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 will change method names.

Thank you!

3
  • Hey, I think you're missing a bit of the question. "We're trying to make sure any Dev end up using these", what does these refer to? Commented Nov 17, 2020 at 13:32
  • sorry, I didn't check what I wrote, I fixed it. Commented Nov 17, 2020 at 13:59
  • Yes, a custom linting rule should be able to do this Commented Nov 18, 2020 at 21:45

1 Answer 1

1

Untested, so mileage may vary from 0 to 100, but you can try the following. Inside a global/ambient ts file write:

declare global {
  interface Function {
    /** @deprecated Don't use this, think about the children!*/
    readonly name: 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

Sign up to request clarification or add additional context in comments.

1 Comment

I kinda help, but it still let you build javascript... it's only a warning... I was thinking of something more intrusive... maybe I'll have to create a tslint rule myself?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.