MCPcopy Index your code
hub / github.com/nodejs/node / checkPropertyInitialization

Function checkPropertyInitialization

test/fixtures/snapshot/typescript.js:84565–84587  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

84563 return ok;
84564 }
84565 function checkPropertyInitialization(node) {
84566 if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) {
84567 return;
84568 }
84569 var constructor = findConstructorDeclaration(node);
84570 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84571 var member = _a[_i];
84572 if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) {
84573 continue;
84574 }
84575 if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
84576 var propName = member.name;
84577 if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84578 var type = getTypeOfSymbol(getSymbolOfNode(member));
84579 if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) {
84580 if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84581 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84582 }
84583 }
84584 }
84585 }
84586 }
84587 }
84588 function isPropertyWithoutInitializer(node) {
84589 return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ &&
84590 !ts.hasAbstractModifier(node) &&

Callers 1

Calls 7

getTypeOfSymbolFunction · 0.85
getSymbolOfNodeFunction · 0.85
getFalsyFlagsFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…