ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
61 lines (47 loc) • 1.63 kB
Markdown
title: Manipulation Settings
## Manipulation Settings
The manipulation settings can be set when creating the main AST object:
```typescript
import * as ts from "typescript";
import TsSimpleAst, {QuoteType, NewLineKind, IndentationText} from "ts-simple-ast";
const ast = new TsSimpleAst({
// these are the defaults
manipulationSettings: {
// TwoSpaces, FourSpaces, EightSpaces, or Tab
indentationText: IndentationText.FourSpaces,
// LineFeed or CarriageReturnLineFeed
newLineKind: NewLineKind.LineFeed,
// defines what ts.ScriptTarget source files are created with
scriptTarget: ts.ScriptTarget.Latest,
// Single or Double
quoteType: QuoteType.Double
}
});
```
You can only provide a partial of these settings if you wish:
```typescript
const ast = new TsSimpleAst({
manipulationSettings: { indentationText: IndentationText.TwoSpaces }
});
```
### Details
Get more details about the settings by looking at the `manipulationSettings` property on the main AST object:
```typescript
ast.manipulationSettings.getIndentationText();
ast.manipulationSettings.getNewLineKind();
ast.manipulationSettings.getQuoteType();
ast.manipulationSettings.getScriptTarget();
```
### Updating
You can update these settings later if you wish by using the `set` method:
```typescript
// set only one
ast.manipulationSettings.set({ quoteType: QuoteType.Single });
// or multiple
ast.manipulationSettings.set({
quoteType: QuoteType.Single,
indentationText: IndentationText.TwoSpaces
});
```