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

Function getTypeScriptMemberSymbols

test/fixtures/snapshot/typescript.js:133638–133717  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133636 return undefined;
133637 }
133638 function getTypeScriptMemberSymbols() {
133639 // Right of dot member completion list
133640 completionKind = 2 /* CompletionKind.PropertyAccess */;
133641 // Since this is qualified name check it's a type node location
133642 var isImportType = ts.isLiteralImportTypeNode(node);
133643 var isTypeLocation = insideJsDocTagTypeExpression
133644 || (isImportType && !node.isTypeOf)
133645 || ts.isPartOfTypeNode(node.parent)
133646 || ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker);
133647 var isRhsOfImportDeclaration = ts.isInRightSideOfInternalImportEqualsDeclaration(node);
133648 if (ts.isEntityName(node) || isImportType || ts.isPropertyAccessExpression(node)) {
133649 var isNamespaceName = ts.isModuleDeclaration(node.parent);
133650 if (isNamespaceName)
133651 isNewIdentifierLocation = true;
133652 var symbol = typeChecker.getSymbolAtLocation(node);
133653 if (symbol) {
133654 symbol = ts.skipAlias(symbol, typeChecker);
133655 if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) {
133656 // Extract module or enum members
133657 var exportedSymbols = typeChecker.getExportsOfModule(symbol);
133658 ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined");
133659 var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : node.parent, symbol.name); };
133660 var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); };
133661 var isValidAccess = isNamespaceName
133662 // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion.
133663 ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); }
133664 : isRhsOfImportDeclaration ?
133665 // Any kind is allowed when dotting off namespace in internal import equals declaration
133666 function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } :
133667 isTypeLocation ? isValidTypeAccess_1 : isValidValueAccess_1;
133668 for (var _i = 0, exportedSymbols_1 = exportedSymbols; _i < exportedSymbols_1.length; _i++) {
133669 var exportedSymbol = exportedSymbols_1[_i];
133670 if (isValidAccess(exportedSymbol)) {
133671 symbols.push(exportedSymbol);
133672 }
133673 }
133674 // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods).
133675 if (!isTypeLocation &&
133676 symbol.declarations &&
133677 symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) {
133678 var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType();
133679 var insertQuestionDot = false;
133680 if (type.isNullableType()) {
133681 var canCorrectToQuestionDot = isRightOfDot &&
133682 !isRightOfQuestionDot &&
133683 preferences.includeAutomaticOptionalChainCompletions !== false;
133684 if (canCorrectToQuestionDot || isRightOfQuestionDot) {
133685 type = type.getNonNullableType();
133686 if (canCorrectToQuestionDot) {
133687 insertQuestionDot = true;
133688 }
133689 }
133690 }
133691 addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot);
133692 }
133693 return;
133694 }
133695 }

Callers 1

getCompletionDataFunction · 0.85

Calls 6

isValidTypeAccess_1Function · 0.85
isValidValueAccess_1Function · 0.85
addTypePropertiesFunction · 0.85
everyMethod · 0.80
someMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected