import { extname } from "path" ; import { CompilerOptions , Project } from "ts-morph" ; function isConfig ( value ) { return typeof value === "string" && extname ( value ) === ".json" ; } export function create ( root ) { const compilerOptions = { allowJs : true , checkJs : true , noEmit : true , resolveJsonModule : true , } ; if ( isConfig ( root ) ) { return new Project ( { compilerOptions , tsConfigFilePath : root } ) ; } const project = new Project ( { compilerOptions , } ) ; project . addSourceFilesAtPaths ( root ) ; project . resolveSourceFileDependencies ( ) ; return project ; }