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

Function visitDeclarationStatements

test/fixtures/snapshot/typescript.js:108930–108977  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

108928 return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */);
108929 }
108930 function visitDeclarationStatements(input) {
108931 if (!isPreservedDeclarationStatement(input)) {
108932 // return undefined for unmatched kinds to omit them from the tree
108933 return;
108934 }
108935 if (shouldStripInternal(input))
108936 return;
108937 switch (input.kind) {
108938 case 272 /* SyntaxKind.ExportDeclaration */: {
108939 if (ts.isSourceFile(input.parent)) {
108940 resultHasExternalModuleIndicator = true;
108941 }
108942 resultHasScopeMarker = true;
108943 // Always visible if the parent node isn't dropped for being not visible
108944 // Rewrite external module names if necessary
108945 return factory.updateExportDeclaration(input,
108946 /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined);
108947 }
108948 case 271 /* SyntaxKind.ExportAssignment */: {
108949 // Always visible if the parent node isn't dropped for being not visible
108950 if (ts.isSourceFile(input.parent)) {
108951 resultHasExternalModuleIndicator = true;
108952 }
108953 resultHasScopeMarker = true;
108954 if (input.expression.kind === 79 /* SyntaxKind.Identifier */) {
108955 return input;
108956 }
108957 else {
108958 var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */);
108959 getSymbolAccessibilityDiagnostic = function () { return ({
108960 diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
108961 errorNode: input
108962 }); };
108963 errorFallbackNode = input;
108964 var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108965 errorFallbackNode = undefined;
108966 var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */));
108967 preserveJsDoc(statement, input);
108968 ts.removeAllComments(input);
108969 return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108970 }
108971 }
108972 }
108973 var result = transformTopLevelDeclaration(input);
108974 // Don't actually transform yet; just leave as original node - will be elided/swapped by late pass
108975 lateStatementReplacementMap.set(ts.getOriginalNodeId(input), result);
108976 return input;
108977 }
108978 function stripExportModifiers(statement) {
108979 if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) {
108980 // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace

Callers

nothing calls this directly

Calls 6

shouldStripInternalFunction · 0.85
rewriteModuleSpecifierFunction · 0.85
preserveJsDocFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…