diff --git a/deno/ts_morph.js b/deno/ts_morph.js index ad7feef54..826b7c793 100644 --- a/deno/ts_morph.js +++ b/deno/ts_morph.js @@ -19132,12 +19132,7 @@ class CompilerFactory { filePath = this.context.fileSystemWrapper.getStandardizedAbsolutePath(filePath); let sourceFile = this.sourceFileCacheByFilePath.get(filePath); if (sourceFile == null) { - let fileText; - try { - fileText = this.context.fileSystemWrapper.readFileSync(filePath, this.context.getEncoding()); - } - catch (_a) { - } + const fileText = this.context.fileSystemWrapper.readFileIfExistsSync(filePath, this.context.getEncoding()); if (fileText != null) { this.context.logger.log(`Loaded file: ${filePath}`); sourceFile = this.createSourceFileFromTextInternal(filePath, fileText, options); diff --git a/packages/ts-morph/src/factories/CompilerFactory.ts b/packages/ts-morph/src/factories/CompilerFactory.ts index e83a45cca..898267ba4 100644 --- a/packages/ts-morph/src/factories/CompilerFactory.ts +++ b/packages/ts-morph/src/factories/CompilerFactory.ts @@ -233,13 +233,7 @@ export class CompilerFactory { filePath = this.context.fileSystemWrapper.getStandardizedAbsolutePath(filePath); let sourceFile = this.sourceFileCacheByFilePath.get(filePath); if (sourceFile == null) { - let fileText: string | undefined; - try { - fileText = this.context.fileSystemWrapper.readFileSync(filePath, this.context.getEncoding()); - } catch { - // ignore - } - + const fileText = this.context.fileSystemWrapper.readFileIfExistsSync(filePath, this.context.getEncoding()); if (fileText != null) { this.context.logger.log(`Loaded file: ${filePath}`); sourceFile = this.createSourceFileFromTextInternal(filePath, fileText, options);