(symbol, isPrivate, propertyAsAlias)
| 54348 | // If it's a class/interface/function: emit a class/interface/function with a `default` modifier |
| 54349 | // These forms can merge, eg (`export default 12; export default interface A {}`) |
| 54350 | function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { |
| 54351 | var _a, _b, _c, _d; |
| 54352 | var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); |
| 54353 | var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; |
| 54354 | if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { |
| 54355 | // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( |
| 54356 | context.encounteredError = true; |
| 54357 | // TODO: Issue error via symbol tracker? |
| 54358 | return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name |
| 54359 | } |
| 54360 | var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ |
| 54361 | || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves |
| 54362 | var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; |
| 54363 | // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is |
| 54364 | if (needsPostExportDefault || needsExportDeclaration) { |
| 54365 | isPrivate = true; |
| 54366 | } |
| 54367 | var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); |
| 54368 | var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && |
| 54369 | symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && |
| 54370 | symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; |
| 54371 | var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); |
| 54372 | if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { |
| 54373 | serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); |
| 54374 | } |
| 54375 | if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { |
| 54376 | serializeTypeAlias(symbol, symbolName, modifierFlags); |
| 54377 | } |
| 54378 | // Need to skip over export= symbols below - json source files get a single `Property` flagged |
| 54379 | // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. |
| 54380 | if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) |
| 54381 | && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ |
| 54382 | && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) |
| 54383 | && !(symbol.flags & 32 /* SymbolFlags.Class */) |
| 54384 | && !isConstMergedWithNSPrintableAsSignatureMerge) { |
| 54385 | if (propertyAsAlias) { |
| 54386 | var createdExport = serializeMaybeAliasAssignment(symbol); |
| 54387 | if (createdExport) { |
| 54388 | needsExportDeclaration = false; |
| 54389 | needsPostExportDefault = false; |
| 54390 | } |
| 54391 | } |
| 54392 | else { |
| 54393 | var type = getTypeOfSymbol(symbol); |
| 54394 | var localName = getInternalSymbolName(symbol, symbolName); |
| 54395 | if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { |
| 54396 | // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns |
| 54397 | serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); |
| 54398 | } |
| 54399 | else { |
| 54400 | // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ |
| 54401 | // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` |
| 54402 | var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) |
| 54403 | ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) |
| 54404 | ? 2 /* NodeFlags.Const */ |
| 54405 | : undefined |
| 54406 | : isConstVariable(symbol) |
| 54407 | ? 2 /* NodeFlags.Const */ |
no test coverage detected
searching dependent graphs…