Allow `originalText` to be passed to `formatAST()` (#4677)

This allows `prettier.__debug.formatAST` to not crash when given the AST
for the below code (taken from https://astexplorer.net/), which is
useful when trying to use Prettier as a code generator for an AST
without corresponding source code (https://github.com/prettier/prettier/issues/4675)

```js
let tips = [
  "Click on any AST node with a '+' to expand it",

  "Hovering over a node highlights the \
   corresponding part in the source code",

  "Shift click on an AST node expands the whole substree"
];

function printTips() {
  tips.forEach((tip, i) => console.log(`Tip ${i}:` + tip));
}
```
master
Joseph Frazier 2018-06-13 12:30:14 -04:00 committed by GitHub
parent f0907a049d
commit 88be12ca07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -9,6 +9,7 @@ const resolveParser = require("./parser").resolveParser;
const hiddenDefaults = {
astFormat: "estree",
printer: {},
originalText: undefined,
locStart: null,
locEnd: null
};