(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags)
| 376 | } |
| 377 | |
| 378 | func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags) *ast.Symbol { |
| 379 | container := b.container |
| 380 | hasExportModifier := ast.GetCombinedModifierFlags(node)&ast.ModifierFlagsExport != 0 || ast.IsImplicitlyExportedJSDocDeclaration(node) |
| 381 | if symbolFlags&ast.SymbolFlagsAlias != 0 { |
| 382 | if node.Kind == ast.KindExportSpecifier || (node.Kind == ast.KindImportEqualsDeclaration && hasExportModifier) { |
| 383 | return b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes) |
| 384 | } |
| 385 | return b.declareSymbol(ast.GetLocals(container), nil /*parent*/, node, symbolFlags, symbolExcludes) |
| 386 | } |
| 387 | // Exported module members are given 2 symbols: A local symbol that is classified with an ExportValue flag, |
| 388 | // and an associated export symbol with all the correct flags set on it. There are 2 main reasons: |
| 389 | // |
| 390 | // 1. We treat locals and exports of the same name as mutually exclusive within a container. |
| 391 | // That means the binder will issue a Duplicate Identifier error if you mix locals and exports |
| 392 | // with the same name in the same container. |
| 393 | // TODO: Make this a more specific error and decouple it from the exclusion logic. |
| 394 | // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, |
| 395 | // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way |
| 396 | // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. |
| 397 | // |
| 398 | // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge |
| 399 | // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation |
| 400 | // and this case is specially handled. Module augmentations should only be merged with original module definition |
| 401 | // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. |
| 402 | if !ast.IsAmbientModule(node) && (hasExportModifier || container.Flags&ast.NodeFlagsExportContext != 0) { |
| 403 | if !ast.IsLocalsContainer(container) || (ast.HasSyntacticModifier(node, ast.ModifierFlagsDefault) && b.getDeclarationName(node) == ast.InternalSymbolNameMissing) { |
| 404 | return b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes) |
| 405 | // No local symbol for an unnamed default! |
| 406 | } |
| 407 | exportKind := ast.SymbolFlagsNone |
| 408 | if symbolFlags&ast.SymbolFlagsValue != 0 { |
| 409 | exportKind = ast.SymbolFlagsExportValue |
| 410 | } |
| 411 | local := b.declareSymbol(ast.GetLocals(container), nil /*parent*/, node, exportKind, symbolExcludes) |
| 412 | local.ExportSymbol = b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes) |
| 413 | node.ExportableData().LocalSymbol = local |
| 414 | return local |
| 415 | } |
| 416 | return b.declareSymbol(ast.GetLocals(container), nil /*parent*/, node, symbolFlags, symbolExcludes) |
| 417 | } |
| 418 | |
| 419 | func (b *Binder) declareClassMember(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags) *ast.Symbol { |
| 420 | if ast.IsStatic(node) { |
no test coverage detected