1import debug from 'debug'; 2import * as ts from 'typescript'; 3import { Extra } from '../parser-options'; 4import { getScriptKind } from './shared'; 5 6const log = debug('typescript-eslint:typescript-estree:createSourceFile'); 7 8function createSourceFile(code: string, extra: Extra): ts.SourceFile { 9 log( 10 'Getting AST without type information in %s mode for: %s', 11 extra.jsx ? 'TSX' : 'TS', 12 extra.filePath, 13 ); 14 15 return ts.createSourceFile( 16 extra.filePath, 17 code, 18 ts.ScriptTarget.Latest, 19 /* setParentNodes */ true, 20 getScriptKind(extra), 21 ); 22} 23 24export { createSourceFile }; 25