Skip to content

Commit a9d65b8

Browse files
author
Andy
authored
textChanges: Clean up *Options interfaces (microsoft#22813)
1 parent faa3fca commit a9d65b8

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/services/textChanges.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace ts.textChanges {
7070
* By default when removing nodes we adjust start and end positions to respect specification of the trivia above.
7171
* If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true
7272
*/
73-
export type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd;
73+
export interface ConfigurableStartEnd extends ConfigurableStart, ConfigurableEnd {}
7474

7575
export const useNonAdjustedPositions: ConfigurableStartEnd = {
7676
useNonAdjustedStartPosition: true,
@@ -113,13 +113,11 @@ namespace ts.textChanges {
113113
readonly range: TextRange;
114114
}
115115

116-
export interface ChangeNodeOptions extends ConfigurableStartEnd, InsertNodeOptions {
117-
readonly useIndentationFromFile?: boolean;
118-
}
116+
export interface ChangeNodeOptions extends ConfigurableStartEnd, InsertNodeOptions {}
119117
interface ReplaceWithSingleNode extends BaseChange {
120118
readonly kind: ChangeKind.ReplaceWithSingleNode;
121119
readonly node: Node;
122-
readonly options?: ChangeNodeOptions;
120+
readonly options?: InsertNodeOptions;
123121
}
124122

125123
interface RemoveNode extends BaseChange {
@@ -131,7 +129,7 @@ namespace ts.textChanges {
131129
interface ReplaceWithMultipleNodes extends BaseChange {
132130
readonly kind: ChangeKind.ReplaceWithMultipleNodes;
133131
readonly nodes: ReadonlyArray<Node>;
134-
readonly options?: ChangeNodeOptions;
132+
readonly options?: InsertNodeOptions;
135133
}
136134

137135
function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, position: Position) {
@@ -283,7 +281,7 @@ namespace ts.textChanges {
283281
}
284282

285283
// TODO (https://github.com/Microsoft/TypeScript/issues/21246): default should probably be useNonAdjustedPositions
286-
public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: ChangeNodeOptions = {}) {
284+
public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) {
287285
this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile, range, options, node: newNode });
288286
return this;
289287
}
@@ -302,7 +300,7 @@ namespace ts.textChanges {
302300
return this.replaceRange(sourceFile, { pos, end }, newNode, options);
303301
}
304302

305-
public replaceRangeWithNodes(sourceFile: SourceFile, range: TextRange, newNodes: ReadonlyArray<Node>, options: ChangeNodeOptions = useNonAdjustedPositions) {
303+
public replaceRangeWithNodes(sourceFile: SourceFile, range: TextRange, newNodes: ReadonlyArray<Node>, options: InsertNodeOptions = {}) {
306304
this.changes.push({ kind: ChangeKind.ReplaceWithMultipleNodes, sourceFile, range, options, nodes: newNodes });
307305
return this;
308306
}
@@ -668,9 +666,7 @@ namespace ts.textChanges {
668666
const initialIndentation =
669667
options.indentation !== undefined
670668
? options.indentation
671-
: (options.useIndentationFromFile !== false)
672-
? formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, options.prefix === newLineCharacter || getLineStartPositionForPosition(pos, sourceFile) === pos)
673-
: 0;
669+
: formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, options.prefix === newLineCharacter || getLineStartPositionForPosition(pos, sourceFile) === pos);
674670
const delta =
675671
options.delta !== undefined
676672
? options.delta

0 commit comments

Comments
 (0)