@@ -1922,10 +1922,11 @@ namespace ts {
1922
1922
if (!isValidTypeOnlyAliasUseSite(useSite)) {
1923
1923
const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
1924
1924
if (typeOnlyDeclaration) {
1925
- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
1925
+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
1926
+ const message = isExport
1926
1927
? Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
1927
1928
: 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
1929
1930
? Diagnostics._0_was_exported_here
1930
1931
: Diagnostics._0_was_imported_here;
1931
1932
const unescapedName = unescapeLeadingUnderscores(name);
@@ -2272,12 +2273,14 @@ namespace ts {
2272
2273
function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node: ImportEqualsDeclaration, resolved: Symbol | undefined) {
2273
2274
if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) {
2274
2275
const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node))!;
2275
- const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
2276
+ const isExport = typeOnlyDeclarationIsExport(typeOnlyDeclaration);
2277
+ const message = isExport
2276
2278
? Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
2277
2279
: 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
2279
2281
? Diagnostics._0_was_exported_here
2280
2282
: Diagnostics._0_was_imported_here;
2283
+
2281
2284
// Non-null assertion is safe because the optionality comes from ImportClause,
2282
2285
// but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
2283
2286
const name = unescapeLeadingUnderscores(typeOnlyDeclaration.name!.escapedText);
@@ -33360,6 +33363,7 @@ namespace ts {
33360
33363
grammarErrorOnFirstToken(node, Diagnostics.An_export_declaration_cannot_have_modifiers);
33361
33364
}
33362
33365
33366
+ checkGrammarExportDeclaration(node);
33363
33367
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
33364
33368
if (node.exportClause) {
33365
33369
// export { x, y }
@@ -33392,6 +33396,14 @@ namespace ts {
33392
33396
}
33393
33397
}
33394
33398
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
+
33395
33407
function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
33396
33408
const isInAppropriateContext = node.parent.kind === SyntaxKind.SourceFile || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.ModuleDeclaration;
33397
33409
if (!isInAppropriateContext) {
0 commit comments