@@ -4413,6 +4413,7 @@ var ts;
44134413 An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
44144414 Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
44154415 Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"),
4416+ Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
44164417 The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
44174418 The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
44184419 Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true),
@@ -14747,6 +14748,10 @@ var ts;
1474714748 || !isExpressionNode(useSite);
1474814749 }
1474914750 ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
14751+ function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
14752+ return typeOnlyDeclaration.kind === 263;
14753+ }
14754+ ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
1475014755 function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
1475114756 while (node.kind === 75 || node.kind === 194) {
1475214757 node = node.parent;
@@ -29486,10 +29491,11 @@ var ts;
2948629491 if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
2948729492 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
2948829493 if (typeOnlyDeclaration) {
29489- var message = typeOnlyDeclaration.kind === 263
29494+ var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
29495+ var message = isExport
2949029496 ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
2949129497 : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
29492- var relatedMessage = typeOnlyDeclaration.kind === 263
29498+ var relatedMessage = isExport
2949329499 ? ts.Diagnostics._0_was_exported_here
2949429500 : ts.Diagnostics._0_was_imported_here;
2949529501 var unescapedName = ts.unescapeLeadingUnderscores(name);
@@ -29761,10 +29767,11 @@ var ts;
2976129767 function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
2976229768 if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) {
2976329769 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
29764- var message = typeOnlyDeclaration.kind === 263
29770+ var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
29771+ var message = isExport
2976529772 ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
2976629773 : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
29767- var relatedMessage = typeOnlyDeclaration.kind === 263
29774+ var relatedMessage = isExport
2976829775 ? ts.Diagnostics._0_was_exported_here
2976929776 : ts.Diagnostics._0_was_imported_here;
2977029777 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
@@ -54422,6 +54429,7 @@ var ts;
5442254429 if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
5442354430 checkExternalEmitHelpers(node, 1048576);
5442454431 }
54432+ checkGrammarExportDeclaration(node);
5442554433 if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
5442654434 if (node.exportClause) {
5442754435 if (ts.isNamedExports(node.exportClause)) {
@@ -54448,6 +54456,14 @@ var ts;
5444854456 }
5444954457 }
5445054458 }
54459+ function checkGrammarExportDeclaration(node) {
54460+ var _a;
54461+ var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261;
54462+ if (isTypeOnlyExportStar) {
54463+ grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
54464+ }
54465+ return !isTypeOnlyExportStar;
54466+ }
5445154467 function checkGrammarModuleElementContext(node, errorMessage) {
5445254468 var isInAppropriateContext = node.parent.kind === 290 || node.parent.kind === 250 || node.parent.kind === 249;
5445354469 if (!isInAppropriateContext) {
@@ -61113,7 +61129,7 @@ var ts;
6111361129 var setter = ts.createPropertyAssignment("set", setterFunction);
6111461130 properties_5.push(setter);
6111561131 }
61116- properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
61132+ properties_5.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()));
6111761133 properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
6111861134 var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
6111961135 receiver,
@@ -69006,7 +69022,7 @@ var ts;
6900669022 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
6900769023 properties.push(setter);
6900869024 }
69009- properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue()));
69025+ properties.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue()));
6901069026 var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
6901169027 target,
6901269028 propertyName,
@@ -72048,6 +72064,9 @@ var ts;
7204872064 if (shouldEmitUnderscoreUnderscoreESModule()) {
7204972065 ts.append(statements, createUnderscoreUnderscoreESModule());
7205072066 }
72067+ if (ts.length(currentModuleInfo.exportedNames)) {
72068+ ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero())));
72069+ }
7205172070 ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
7205272071 ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
7205372072 addExportEqualsIfNeeded(statements, false);
@@ -72160,6 +72179,9 @@ var ts;
7216072179 if (shouldEmitUnderscoreUnderscoreESModule()) {
7216172180 ts.append(statements, createUnderscoreUnderscoreESModule());
7216272181 }
72182+ if (ts.length(currentModuleInfo.exportedNames)) {
72183+ ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero())));
72184+ }
7216372185 ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
7216472186 if (moduleKind === ts.ModuleKind.AMD) {
7216572187 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
@@ -72544,7 +72566,7 @@ var ts;
7254472566 }
7254572567 variables = ts.append(variables, variable);
7254672568 }
72547- else {
72569+ else if (variable.initializer) {
7254872570 expressions = ts.append(expressions, transformInitializedVariable(variable));
7254972571 }
7255072572 }
0 commit comments