MCPcopy Create free account
hub / github.com/nodejs/node / getPropertiesForObjectExpression

Function getPropertiesForObjectExpression

test/fixtures/snapshot/typescript.js:135174–135192  ·  view source on GitHub ↗
(contextualType, completionsType, obj, checker)

Source from the content-addressed store, hash-verified

135172 });
135173 }
135174 function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) {
135175 var hasCompletionsType = completionsType && completionsType !== contextualType;
135176 var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */)
135177 ? checker.getUnionType([contextualType, completionsType])
135178 : contextualType;
135179 var properties = getApparentProperties(type, obj, checker);
135180 return type.isClass() && containsNonPublicProperties(properties) ? [] :
135181 hasCompletionsType ? ts.filter(properties, hasDeclarationOtherThanSelf) : properties;
135182 // Filter out members whose only declaration is the object literal itself to avoid
135183 // self-fulfilling completions like:
135184 //
135185 // function f<T>(x: T) {}
135186 // f({ abc/**/: "" }) // `abc` is a member of `T` but only because it declares itself
135187 function hasDeclarationOtherThanSelf(member) {
135188 if (!ts.length(member.declarations))
135189 return true;
135190 return ts.some(member.declarations, function (decl) { return decl.parent !== obj; });
135191 }
135192 }
135193 Completions.getPropertiesForObjectExpression = getPropertiesForObjectExpression;
135194 function getApparentProperties(type, node, checker) {
135195 if (!type.isUnion())

Callers 2

Calls 3

getApparentPropertiesFunction · 0.85
filterMethod · 0.65

Tested by

no test coverage detected