mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
If there is an export default x; alias declaration, disallow other default exports (#19872)
This commit is contained in:
@@ -2205,15 +2205,14 @@ namespace ts {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
|
||||
}
|
||||
else {
|
||||
// An export default clause with an expression exports a value
|
||||
// We want to exclude both class and function here, this is necessary to issue an error when there are both
|
||||
// default export-assignment and default export function and class declaration.
|
||||
const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node)
|
||||
const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node)
|
||||
// An export default clause with an EntityNameExpression exports all meanings of that identifier
|
||||
? SymbolFlags.Alias
|
||||
// An export default clause with any other expression exports a value
|
||||
: SymbolFlags.Property;
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.Property | SymbolFlags.AliasExcludes | SymbolFlags.Class | SymbolFlags.Function);
|
||||
// If there is an `export default x;` alias declaration, can't `export default` anything else.
|
||||
// (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.)
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.All);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3021,6 +3021,10 @@ namespace ts {
|
||||
Optional = 1 << 24, // Optional property
|
||||
Transient = 1 << 25, // Transient symbol (created during type check)
|
||||
|
||||
/* @internal */
|
||||
All = FunctionScopedVariable | BlockScopedVariable | Property | EnumMember | Function | Class | Interface | ConstEnum | RegularEnum | ValueModule | NamespaceModule | TypeLiteral
|
||||
| ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient,
|
||||
|
||||
Enum = RegularEnum | ConstEnum,
|
||||
Variable = FunctionScopedVariable | BlockScopedVariable,
|
||||
Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor,
|
||||
|
||||
Reference in New Issue
Block a user