Skip to content

Commit 9387b19

Browse files
committed
Fix a minor issue where Span.getModifiedText() sometimes excluded the leading trivia for a source file
1 parent 7e55d2c commit 9387b19

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • apps/api-extractor/src/analyzer

apps/api-extractor/src/analyzer/Span.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ export class SpanModification {
1414
* @remarks
1515
* Also, the modify() operation will not recurse into these spans.
1616
*/
17-
public omitChildren: boolean;
17+
public omitChildren: boolean = false;
1818

1919
/**
2020
* If true, then the Span.separator will be removed from the Span.getModifiedText() output.
2121
*/
22-
public omitSeparatorAfter: boolean;
22+
public omitSeparatorAfter: boolean = false;
2323

2424
/**
2525
* If true, then Span.getModifiedText() will sort the immediate children according to their Span.sortKey
2626
* property. The separators will also be fixed up to ensure correct indentation. If the Span.sortKey is undefined
2727
* for some items, those items will not be moved, i.e. their array indexes will be unchanged.
2828
*/
29-
public sortChildren: boolean;
29+
public sortChildren: boolean = false;
3030

3131
/**
3232
* Used if the parent span has Span.sortChildren=true.
@@ -133,7 +133,7 @@ export class Span {
133133

134134
public constructor(node: ts.Node) {
135135
this.node = node;
136-
this.startIndex = node.getStart();
136+
this.startIndex = node.kind === ts.SyntaxKind.SourceFile ? node.getFullStart() : node.getStart();
137137
this.endIndex = node.end;
138138
this._separatorStartIndex = 0;
139139
this._separatorEndIndex = 0;

0 commit comments

Comments
 (0)