@@ -1936,10 +1936,11 @@ namespace ts {
19361936 if (!isValidTypeOnlyAliasUseSite(useSite)) {
19371937 const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
19381938 if (typeOnlyDeclaration) {
1939- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
1939+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
1940+ const message = isExport
19401941 ? Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
19411942 : 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
19431944 ? Diagnostics._0_was_exported_here
19441945 : Diagnostics._0_was_imported_here;
19451946 const unescapedName = unescapeLeadingUnderscores(name);
@@ -2286,12 +2287,14 @@ namespace ts {
22862287 function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node: ImportEqualsDeclaration, resolved: Symbol | undefined) {
22872288 if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) {
22882289 const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node))!;
2289- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
2290+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
2291+ const message = isExport
22902292 ? Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
22912293 : 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
22932295 ? Diagnostics._0_was_exported_here
22942296 : Diagnostics._0_was_imported_here;
2297+
22952298 // Non-null assertion is safe because the optionality comes from ImportClause,
22962299 // but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
22972300 const name = unescapeLeadingUnderscores(typeOnlyDeclaration.name!.escapedText);
@@ -33598,6 +33601,7 @@ namespace ts {
3359833601 checkExternalEmitHelpers(node, ExternalEmitHelpers.CreateBinding);
3359933602 }
3360033603
33604+ checkGrammarExportDeclaration(node);
3360133605 if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
3360233606 if (node.exportClause) {
3360333607 // export { x, y }
@@ -33630,6 +33634,14 @@ namespace ts {
3363033634 }
3363133635 }
3363233636
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+
3363333645 function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
3363433646 const isInAppropriateContext = node.parent.kind === SyntaxKind.SourceFile || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.ModuleDeclaration;
3363533647 if (!isInAppropriateContext) {
0 commit comments