@@ -1936,10 +1936,11 @@ namespace ts {
1936
1936
if (!isValidTypeOnlyAliasUseSite(useSite)) {
1937
1937
const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
1938
1938
if (typeOnlyDeclaration) {
1939
- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
1939
+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
1940
+ const message = isExport
1940
1941
? Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
1941
1942
: Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
1942
- const relatedMessage = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
1943
+ const relatedMessage = isExport
1943
1944
? Diagnostics._0_was_exported_here
1944
1945
: Diagnostics._0_was_imported_here;
1945
1946
const unescapedName = unescapeLeadingUnderscores(name);
@@ -2286,12 +2287,14 @@ namespace ts {
2286
2287
function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node: ImportEqualsDeclaration, resolved: Symbol | undefined) {
2287
2288
if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) {
2288
2289
const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node))!;
2289
- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
2290
+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
2291
+ const message = isExport
2290
2292
? Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
2291
2293
: Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
2292
- const relatedMessage = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
2294
+ const relatedMessage = isExport
2293
2295
? Diagnostics._0_was_exported_here
2294
2296
: Diagnostics._0_was_imported_here;
2297
+
2295
2298
// Non-null assertion is safe because the optionality comes from ImportClause,
2296
2299
// but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
2297
2300
const name = unescapeLeadingUnderscores(typeOnlyDeclaration.name!.escapedText);
@@ -33598,6 +33601,7 @@ namespace ts {
33598
33601
checkExternalEmitHelpers(node, ExternalEmitHelpers.CreateBinding);
33599
33602
}
33600
33603
33604
+ checkGrammarExportDeclaration(node);
33601
33605
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
33602
33606
if (node.exportClause) {
33603
33607
// export { x, y }
@@ -33630,6 +33634,14 @@ namespace ts {
33630
33634
}
33631
33635
}
33632
33636
33637
+ function checkGrammarExportDeclaration(node: ExportDeclaration): boolean {
33638
+ const isTypeOnlyExportStar = node.isTypeOnly && node.exportClause?.kind !== SyntaxKind.NamedExports;
33639
+ if (isTypeOnlyExportStar) {
33640
+ grammarErrorOnNode(node, Diagnostics.Only_named_exports_may_use_export_type);
33641
+ }
33642
+ return !isTypeOnlyExportStar;
33643
+ }
33644
+
33633
33645
function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
33634
33646
const isInAppropriateContext = node.parent.kind === SyntaxKind.SourceFile || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.ModuleDeclaration;
33635
33647
if (!isInAppropriateContext) {
0 commit comments