CodeQL documentation

Use of incompletely initialized object

ID: js/incomplete-object-initialization
Kind: problem
Security severity: 
Severity: error
Precision: high
Tags:
   - quality
   - reliability
   - correctness
   - language-features
Query suites:
   - javascript-security-and-quality.qls

Click to see the query in the CodeQL repository

If a class extends another class, its constructor needs to call the super constructor before referencing this or accessing properties through super. Failure to do so will cause a runtime error.

Recommendation

Insert a super constructor call.

Example

In the following example, class A extends class B, but its constructor assigns to this.x without first invoking the super constructor, which will cause a runtime error.

class A extends B {
  constructor() { this.x = 42; }
}

To prevent the error, a super constructor call should be inserted:

class A extends B {
  constructor() { super(); this.x = 42; }
}

References

  • © GitHub, Inc.
  • Terms
  • Privacy
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy