Skip to content

⬅️ Back to Table of Contents

📄 createCompilerOptions

📊 Analysis Summary

Metric Count
🔧 Functions 1

📚 Table of Contents

🛠️ File Location:

📂 packages/website/src/components/lib/createCompilerOptions.ts

Functions

createCompilerOptions(tsConfig: Record<string, unknown>): ts.CompilerOptions

Converts compiler options from JSON to ts.CompilerOptions

Raw JSDoc
/**
 * Converts compiler options from JSON to ts.CompilerOptions
 */

Calls:

  • window.ts.convertCompilerOptionsFromJson
  • Array.isArray
  • window.ts.getDefaultLibFileName
Code
export function createCompilerOptions(
  tsConfig: Record<string, unknown> = {},
): ts.CompilerOptions {
  const config = window.ts.convertCompilerOptionsFromJson(
    {
      jsx: 'preserve',
      module: 'esnext',
      target: 'esnext',
      ...tsConfig,
      baseUrl: undefined,
      lib: Array.isArray(tsConfig.lib) ? tsConfig.lib : undefined,
      moduleDetection: undefined,
      moduleResolution: undefined,
      paths: undefined,
      plugins: undefined,
      typeRoots: undefined,
    },
    '/tsconfig.json',
  );

  const options = config.options;

  options.lib ??= [window.ts.getDefaultLibFileName(options)];

  return options;
}

Generated by Syntax Scribe