From 2b92d94b4dfd5ded5966e9995b50156d54727cce Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 12 Sep 2023 01:57:09 -0700 Subject: [PATCH] Clean up some error handling when loading `tsconfig.json` --- src/resolver/resolver.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index d1af1a5990..6a1b428797 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -3871,9 +3871,9 @@ pub const Resolver = struct { ) catch |err| brk: { const pretty = r.prettyPath(Path.init(tsconfigpath)); - if (err == error.ENOENT) { + if (err == error.ENOENT or err == error.FileNotFound) { r.log.addErrorFmt(null, logger.Loc.Empty, r.allocator, "Cannot find tsconfig file \"{s}\"", .{pretty}) catch unreachable; - } else if (err != error.ParseErrorAlreadyLogged and err != error.IsDir) { + } else if (err != error.ParseErrorAlreadyLogged and err != error.IsDir and err != error.EISDIR) { r.log.addErrorFmt(null, logger.Loc.Empty, r.allocator, "Cannot read file \"{s}\": {s}", .{ pretty, @errorName(err) }) catch unreachable; } break :brk null; @@ -3886,7 +3886,12 @@ pub const Resolver = struct { var ts_dir_name = Dirname.dirname(current.abs_path); // not sure why this needs cwd but we'll just pass in the dir of the tsconfig... var abs_path = ResolvePath.joinAbsStringBuf(ts_dir_name, bufs(.tsconfig_path_abs), &[_]string{ ts_dir_name, current.extends }, .auto); - var parent_config_maybe = try r.parseTSConfig(abs_path, 0); + var parent_config_maybe = r.parseTSConfig(abs_path, 0) catch |err| { + r.log.addWarningFmt(null, logger.Loc.Empty, r.allocator, "{s} loading tsconfig.json extends {s}", .{ @errorName(err), strings.QuotedFormatter{ + .text = abs_path, + } }) catch {}; + break; + }; if (parent_config_maybe) |parent_config| { try parent_configs.append(parent_config); current = parent_config;