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

Function transformTopLevelDeclaration

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

Source from the content-addressed store, hash-verified

108985 return factory.updateModifiers(statement, modifiers);
108986 }
108987 function transformTopLevelDeclaration(input) {
108988 if (lateMarkedStatements) {
108989 while (ts.orderedRemoveItem(lateMarkedStatements, input))
108990 ;
108991 }
108992 if (shouldStripInternal(input))
108993 return;
108994 switch (input.kind) {
108995 case 265 /* SyntaxKind.ImportEqualsDeclaration */: {
108996 return transformImportEqualsDeclaration(input);
108997 }
108998 case 266 /* SyntaxKind.ImportDeclaration */: {
108999 return transformImportDeclaration(input);
109000 }
109001 }
109002 if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
109003 return;
109004 // Elide implementation signatures from overload sets
109005 if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
109006 return;
109007 var previousEnclosingDeclaration;
109008 if (isEnclosingDeclaration(input)) {
109009 previousEnclosingDeclaration = enclosingDeclaration;
109010 enclosingDeclaration = input;
109011 }
109012 var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
109013 var oldDiag = getSymbolAccessibilityDiagnostic;
109014 if (canProdiceDiagnostic) {
109015 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
109016 }
109017 var previousNeedsDeclare = needsDeclare;
109018 switch (input.kind) {
109019 case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
109020 return cleanup(factory.updateTypeAliasDeclaration(input,
109021 /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
109022 case 258 /* SyntaxKind.InterfaceDeclaration */: {
109023 return cleanup(factory.updateInterfaceDeclaration(input,
109024 /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
109025 }
109026 case 256 /* SyntaxKind.FunctionDeclaration */: {
109027 // Generators lose their generator-ness, excepting their return type
109028 var clean = cleanup(factory.updateFunctionDeclaration(input,
109029 /*decorators*/ undefined, ensureModifiers(input),
109030 /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type),
109031 /*body*/ undefined));
109032 if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) {
109033 var props = resolver.getPropertiesOfContainerFunction(input);
109034 // Use parseNodeFactory so it is usable as an enclosing declaration
109035 var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */);
109036 ts.setParent(fakespace_1, enclosingDeclaration);
109037 fakespace_1.locals = ts.createSymbolTable(props);
109038 fakespace_1.symbol = props[0].parent;
109039 var exportMappings_1 = [];
109040 var declarations = ts.mapDefined(props, function (p) {
109041 if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) {
109042 return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them)
109043 }
109044 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);

Calls 15

shouldStripInternalFunction · 0.85
isEnclosingDeclarationFunction · 0.85
ensureModifiersFunction · 0.85
ensureTypeParamsFunction · 0.85
transformHeritageClausesFunction · 0.85
updateParamsListFunction · 0.85
ensureTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…