Skip to content

Commit 8759eb9

Browse files
committed
Allow use before declaration for export= assignments
1 parent ac09853 commit 8759eb9

File tree

4 files changed

+6
-59
lines changed

4 files changed

+6
-59
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,17 @@ namespace ts {
794794
// 2. inside a function
795795
// 3. inside an instance property initializer, a reference to a non-instance property
796796
// 4. inside a static property initializer, a reference to a static method in the same class
797+
// 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ)
797798
// or if usage is in a type context:
798799
// 1. inside a type query (typeof in type position)
799-
if (usage.parent.kind === SyntaxKind.ExportSpecifier) {
800+
if (usage.parent.kind === SyntaxKind.ExportSpecifier || (usage.parent.kind === SyntaxKind.ExportAssignment && (usage.parent as ExportAssignment).isExportEquals)) {
800801
// export specifiers do not use the variable, they only make it available for use
801802
return true;
802803
}
804+
// When resolving symbols for exports, the `usage` location passed in can be the export site directly
805+
if (usage.kind === SyntaxKind.ExportAssignment && (usage as ExportAssignment).isExportEquals) {
806+
return true;
807+
}
803808

804809
const container = getEnclosingBlockScopeContainer(declaration);
805810
return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container);

tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/baselines/reference/exportImport.errors.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)