@@ -1922,10 +1922,11 @@ namespace ts {
19221922 if (!isValidTypeOnlyAliasUseSite(useSite)) {
19231923 const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
19241924 if (typeOnlyDeclaration) {
1925- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
1925+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
1926+ const message = isExport
19261927 ? Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
19271928 : Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
1928- const relatedMessage = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
1929+ const relatedMessage = isExport
19291930 ? Diagnostics._0_was_exported_here
19301931 : Diagnostics._0_was_imported_here;
19311932 const unescapedName = unescapeLeadingUnderscores(name);
@@ -2272,12 +2273,14 @@ namespace ts {
22722273 function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node: ImportEqualsDeclaration, resolved: Symbol | undefined) {
22732274 if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) {
22742275 const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node))!;
2275- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
2276+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
2277+ const message = isExport
22762278 ? Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
22772279 : Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
2278- const relatedMessage = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
2280+ const relatedMessage = isExport
22792281 ? Diagnostics._0_was_exported_here
22802282 : Diagnostics._0_was_imported_here;
2283+
22812284 // Non-null assertion is safe because the optionality comes from ImportClause,
22822285 // but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
22832286 const name = unescapeLeadingUnderscores(typeOnlyDeclaration.name!.escapedText);
@@ -33360,6 +33363,7 @@ namespace ts {
3336033363 grammarErrorOnFirstToken(node, Diagnostics.An_export_declaration_cannot_have_modifiers);
3336133364 }
3336233365
33366+ checkGrammarExportDeclaration(node);
3336333367 if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
3336433368 if (node.exportClause) {
3336533369 // export { x, y }
@@ -33392,6 +33396,14 @@ namespace ts {
3339233396 }
3339333397 }
3339433398
33399+ function checkGrammarExportDeclaration(node: ExportDeclaration): boolean {
33400+ const isTypeOnlyExportStar = node.isTypeOnly && node.exportClause?.kind !== SyntaxKind.NamedExports;
33401+ if (isTypeOnlyExportStar) {
33402+ grammarErrorOnNode(node, Diagnostics.Only_named_exports_may_use_export_type);
33403+ }
33404+ return !isTypeOnlyExportStar;
33405+ }
33406+
3339533407 function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
3339633408 const isInAppropriateContext = node.parent.kind === SyntaxKind.SourceFile || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.ModuleDeclaration;
3339733409 if (!isInAppropriateContext) {
0 commit comments