Skip to content

Commit 0998c93

Browse files
fix(es/codegen): Restore missing top-level comments (#11302)
This fixes an issue where top-level comments (like copyright headers) were being lost after PR #11199 changed Module/Script spans to start at position 0. The fix skips emitting leading comments at Module/Script level when the body is non-empty. Instead, comments are emitted by the first body item with a real source span. Injected imports have DUMMY_SP, so they skip comment emission, and original source items emit their comments correctly after the imports. Closes #11167 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Donny/강동윤 <[email protected]>
1 parent 0fc7496 commit 0998c93

File tree

3,460 files changed

+3587
-3540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,460 files changed

+3587
-3540
lines changed

.changeset/few-bees-crash.md

Lines changed: 7 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
//// [ambientAccessors.ts]
2+
// ok to use accessors in ambient class in ES3

crates/swc/tests/tsc-references/ambientDeclarationsExternal.1.normal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//// [ambientDeclarationsExternal.ts]
22
//// [decls.ts]
3+
// Ambient external module with export assignment
34
// Ambient external import declaration referencing ambient external module using top level module name
45
//// [consumer.ts]
56
//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
//// [ambientEnumDeclaration1.ts]
2+
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
//// [ambientEnumDeclaration2.ts]
2+
// In ambient enum declarations that specify no const modifier, enum member declarations
3+
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).

crates/swc/tests/tsc-references/arraySpreadImportHelpers.1.normal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ var o = [
1212
]);
1313
export { };
1414
//// [tslib.d.ts]
15+
// this is a pre-TS4.4 versions of emit helper, which always forced array packing
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
//// [callSignaturesThatDifferOnlyByReturnType3.ts]
2+
// Normally it is an error to have multiple overloads with identical signatures in a single type declaration.
3+
// Here the multiple overloads come from multiple merged declarations.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
//// [constEnum1.ts]
2+
// An enum declaration that specifies a const modifier is a constant enum declaration.
3+
// In a constant enum declaration, all members must have constant values and
4+
// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
//// [derivedInterfaceDoesNotHideBaseSignatures.ts]
2+
// Derived interfaces no longer hide signatures from base types, so these signatures are always compatible.

crates/swc/tests/tsc-references/enumMergeWithExpando.1.normal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [lovefield-ts.d.ts]
2+
// bug #27352, crashes from github.com/google/lovefield
23
//// [enums.js]
34
lf.Order = {};
45
lf.Order.DESC = 0;

0 commit comments

Comments
 (0)