Skip to content

Commit

Permalink
Conditionally enable .[tj]sx extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Jan 26, 2019
1 parent 7f5284c commit 062254f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/index.ts
Expand Up @@ -210,7 +210,7 @@ export function register (opts: Options = {}): Register {
const fileExists = options.fileExists || ts.sys.fileExists
const config = readConfig(cwd, ts, fileExists, readFile, options)
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics)
const extensions = ['.ts', '.tsx']
const extensions = ['.ts']

const diagnosticHost: _ts.FormatDiagnosticsHost = {
getNewLine: () => EOL,
Expand All @@ -231,11 +231,10 @@ export function register (opts: Options = {}): Register {
// Render the configuration errors and exit the script.
if (configDiagnosticList.length) throw createTSError(configDiagnosticList)

// Enable `allowJs` when flag is set.
if (config.options.allowJs) {
extensions.push('.js')
extensions.push('.jsx')
}
// Enable additional extensions when JSX or `allowJs` is enabled.
if (config.options.jsx) extensions.push('.tsx')
if (config.options.allowJs) extensions.push('.js')
if (config.options.jsx && config.options.allowJs) extensions.push('.jsx')

// Initialize files from TypeScript into project.
for (const path of config.fileNames) memoryCache.versions[path] = 1
Expand Down

0 comments on commit 062254f

Please sign in to comment.