From 7df81488ab42a1198d5f4a8ccbbdf40cd1095ed6 Mon Sep 17 00:00:00 2001 From: Brent Erickson Date: Wed, 6 May 2020 15:35:51 -0700 Subject: [PATCH] Fix #905 Ensure that json files are resolved if resolveJsonModule flag is set in tsconfig --- src/instances.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/instances.ts b/src/instances.ts index c8b99c1e5..195f733d0 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -351,6 +351,13 @@ export function initializeInstance( } function getScriptRegexp(instance: TSInstance) { + // If resolveJsonModules is set, we should accept json files + if (instance.configParseResult.options.resolveJsonModule) { + // if allowJs is set then we should accept js(x) files + return instance.configParseResult.options.allowJs === true + ? /\.tsx?$|\.json$|\.jsx?$/i + : /\.tsx?$|\.json$/i; + } // if allowJs is set then we should accept js(x) files return instance.configParseResult.options.allowJs === true ? /\.tsx?$|\.jsx?$/i