(node)
| 81141 | addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); }); |
| 81142 | } |
| 81143 | function checkExportsOnMergedDeclarationsWorker(node) { |
| 81144 | // if localSymbol is defined on node then node itself is exported - check is required |
| 81145 | var symbol = node.localSymbol; |
| 81146 | if (!symbol) { |
| 81147 | // local symbol is undefined => this declaration is non-exported. |
| 81148 | // however symbol might contain other declarations that are exported |
| 81149 | symbol = getSymbolOfNode(node); |
| 81150 | if (!symbol.exportSymbol) { |
| 81151 | // this is a pure local symbol (all declarations are non-exported) - no need to check anything |
| 81152 | return; |
| 81153 | } |
| 81154 | } |
| 81155 | // run the check only for the first declaration in the list |
| 81156 | if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { |
| 81157 | return; |
| 81158 | } |
| 81159 | var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; |
| 81160 | var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; |
| 81161 | var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; |
| 81162 | for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { |
| 81163 | var d = _a[_i]; |
| 81164 | var declarationSpaces = getDeclarationSpaces(d); |
| 81165 | var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); |
| 81166 | if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { |
| 81167 | if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { |
| 81168 | defaultExportedDeclarationSpaces |= declarationSpaces; |
| 81169 | } |
| 81170 | else { |
| 81171 | exportedDeclarationSpaces |= declarationSpaces; |
| 81172 | } |
| 81173 | } |
| 81174 | else { |
| 81175 | nonExportedDeclarationSpaces |= declarationSpaces; |
| 81176 | } |
| 81177 | } |
| 81178 | // Spaces for anything not declared a 'default export'. |
| 81179 | var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; |
| 81180 | var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; |
| 81181 | var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; |
| 81182 | if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { |
| 81183 | // declaration spaces for exported and non-exported declarations intersect |
| 81184 | for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { |
| 81185 | var d = _c[_b]; |
| 81186 | var declarationSpaces = getDeclarationSpaces(d); |
| 81187 | var name = ts.getNameOfDeclaration(d); |
| 81188 | // Only error on the declarations that contributed to the intersecting spaces. |
| 81189 | if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { |
| 81190 | error(name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(name)); |
| 81191 | } |
| 81192 | else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { |
| 81193 | error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name)); |
| 81194 | } |
| 81195 | } |
| 81196 | } |
| 81197 | function getDeclarationSpaces(decl) { |
| 81198 | var d = decl; |
| 81199 | switch (d.kind) { |
| 81200 | case 258 /* SyntaxKind.InterfaceDeclaration */: |
no test coverage detected