(
this: Parser,
node: Undone<
| N.ExportDefaultDeclaration
| N.ExportAllDeclaration
| N.ExportNamedDeclaration
>,
decorators: N.Decorator[] | null | undefined,
)
| 2277 | // https://tc39.es/ecma262/#prod-ExportDeclaration |
| 2278 | |
| 2279 | parseExport( |
| 2280 | this: Parser, |
| 2281 | node: Undone< |
| 2282 | | N.ExportDefaultDeclaration |
| 2283 | | N.ExportAllDeclaration |
| 2284 | | N.ExportNamedDeclaration |
| 2285 | >, |
| 2286 | decorators: N.Decorator[] | null | undefined, |
| 2287 | ): N.AnyExport { |
| 2288 | const maybeDefaultIdentifier = this.parseMaybeImportPhase( |
| 2289 | node, |
| 2290 | /* isExport */ true, |
| 2291 | ); |
| 2292 | const hasDefault = this.maybeParseExportDefaultSpecifier( |
| 2293 | node, |
| 2294 | maybeDefaultIdentifier, |
| 2295 | ); |
| 2296 | const parseAfterDefault = !hasDefault || this.eat(tt.comma); |
| 2297 | const hasStar = parseAfterDefault && this.eatExportStar(node); |
| 2298 | const hasNamespace = |
| 2299 | hasStar && this.maybeParseExportNamespaceSpecifier(node); |
| 2300 | // `export * as ns` must be followed by `from` (ExportFromClause). |
| 2301 | const parseAfterNamespace = parseAfterDefault && !hasNamespace; |
| 2302 | |
| 2303 | if (hasStar && !hasNamespace) { |
| 2304 | if (hasDefault) this.unexpected(); |
| 2305 | if (decorators) { |
| 2306 | throw this.raise(Errors.UnsupportedDecoratorExport, node); |
| 2307 | } |
| 2308 | if ((node as N.ExportNamedDeclaration).phase === "defer") { |
| 2309 | this.raise(Errors.DeferExportInvalidAll, node); |
| 2310 | } |
| 2311 | this.parseExportFrom(node, true); |
| 2312 | |
| 2313 | this.sawUnambiguousESM = true; |
| 2314 | |
| 2315 | return this.finishNode(node, "ExportAllDeclaration"); |
| 2316 | } |
| 2317 | |
| 2318 | const hasSpecifiers = |
| 2319 | parseAfterNamespace && this.maybeParseExportNamedSpecifiers(node); |
| 2320 | const isFromRequired = |
| 2321 | hasDefault || |
| 2322 | hasStar || |
| 2323 | (node as Undone<N.ExportNamedDeclaration>).phase === "defer" || |
| 2324 | // export { x, y } as ns from '...' |
| 2325 | (hasSpecifiers && |
| 2326 | node.specifiers[0]?.type === "ExportNamespaceSpecifier"); |
| 2327 | |
| 2328 | if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) { |
| 2329 | this.unexpected(null, tt.braceL); |
| 2330 | } |
| 2331 | |
| 2332 | let hasDeclaration; |
| 2333 | if (isFromRequired || hasSpecifiers) { |
| 2334 | hasDeclaration = false; |
| 2335 | if (decorators) { |
| 2336 | throw this.raise(Errors.UnsupportedDecoratorExport, node); |
nothing calls this directly
no test coverage detected