Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

89
Views
Define a classes possible properties

I don't want to turn off an code inspections, but is there a way I can define what class properties could be defined, so when using methods within the class I'm not getting Unresolved variable warning?

enter image description here

I would use TypeScript however I can't do that right now. Is there another way? There's many properties that can be set or not set.

I can remove this within the constructor by defining what value can contain:

enter image description here

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

Define class properties and write jsdoc like this:

class Base {
  /**
   * @type {boolean}
   */

  disableReset;

  /**
   * @param {boolean} disableReset
   */
  constructor(disableReset) {
    this.disableReset = disableReset;
  }
  reset() {
    if (this.disableReset) {
      // do stuff
    }
  }
}

enter image description here

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs