Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Use of incompletely initialized object

ID: js/incomplete-object-initializationKind: problemSecurity severity: Severity: errorPrecision: highTags:   - quality   - reliability   - correctness   - language-featuresQuery suites:   - javascript-code-quality.qls   - 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 referencingthis or accessing properties throughsuper. Failure to do so will cause a runtime error.

Recommendation

Insert a super constructor call.

Example

In the following example, classA extends classB, but its constructor assigns tothis.x without first invoking the super constructor, which will cause a runtime error.

classAextendsB{constructor(){this.x=42;}}

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

classAextendsB{constructor(){super();this.x=42;}}

References


[8]ページ先頭

©2009-2026 Movatter.jp