@@ -46,11 +46,13 @@ function resetExtra() {
46
46
47
47
/**
48
48
* Parses the given source code to produce a valid AST
49
- * @param {mixed } code TypeScript code
50
- * @param {Object } options configuration object for the parser
49
+ * @param {mixed } code TypeScript code
50
+ * @param {Object } options configuration object for the parser
51
+ * @param {Object } additionalParsingContext additional internal configuration
51
52
* @returns {Object } the AST
52
53
*/
53
- function parse ( code , options ) {
54
+ function generateAST ( code , options , additionalParsingContext ) {
55
+ additionalParsingContext = additionalParsingContext || { } ;
54
56
55
57
const toString = String ;
56
58
@@ -109,7 +111,7 @@ function parse(code, options) {
109
111
* Provide the context as to whether or not we are parsing for ESLint,
110
112
* specifically
111
113
*/
112
- if ( options . parseForESLint ) {
114
+ if ( additionalParsingContext . isParseForESLint ) {
113
115
extra . parseForESLint = true ;
114
116
}
115
117
}
@@ -183,11 +185,12 @@ function parse(code, options) {
183
185
184
186
exports . version = require ( "./package.json" ) . version ;
185
187
186
- exports . parse = parse ;
188
+ exports . parse = function parse ( code , options ) {
189
+ return generateAST ( code , options , { isParseForESLint : false } ) ;
190
+ } ;
187
191
188
192
exports . parseForESLint = function parseForESLint ( code , options ) {
189
- options . parseForESLint = true ;
190
- const ast = parse ( code , options ) ;
193
+ const ast = generateAST ( code , options , { isParseForESLint : true } ) ;
191
194
return { ast } ;
192
195
} ;
193
196
0 commit comments