Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

WIP: refactor converting #80

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/ast-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright jQuery Foundation and other contributors, https://jquery.org/
* MIT License
*/
import convert, { getASTMaps, resetASTMaps, convertError } from './convert';
import Converter, { convertError } from './convert';
import { convertComments } from './convert-comments';
import nodeUtils from './node-utils';
import ts from 'typescript';
Expand All @@ -27,16 +27,12 @@ export default (
/**
* Recursively convert the TypeScript AST into an ESTree-compatible AST
*/
const estree: any = convert({
node: ast,
parent: null,
ast,
additionalOptions: {
errorOnUnknownASTType: extra.errorOnUnknownASTType || false,
useJSXTextNode: extra.useJSXTextNode || false,
shouldProvideParserServices
}
const instance = new Converter(ast, {
errorOnUnknownASTType: extra.errorOnUnknownASTType || false,
useJSXTextNode: extra.useJSXTextNode || false,
shouldProvideParserServices
});
const estree: any = instance.convertProgram(ast);

/**
* Optionally convert and include all tokens in the AST
Expand All @@ -54,8 +50,7 @@ export default (

let astMaps = undefined;
if (shouldProvideParserServices) {
astMaps = getASTMaps();
resetASTMaps();
astMaps = instance.getASTMaps();
}

return { estree, astMaps };
Expand Down
Loading