Skip to content

⬅️ Back to Table of Contents

📄 createCompilerOptions.ts

📊 Analysis Summary

Metric Count
🔧 Functions 1
📊 Variables & Constants 1

📚 Table of Contents

🛠️ File Location:

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

Variables & Constants

Name Type Kind Value Exported
options any const config.options

Functions

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

Code
export function createCompilerOptions(
  tsConfig: Record<string, unknown> = {},
): ts.CompilerOptions {
  const config = window.ts.convertCompilerOptionsFromJson(
    {
      jsx: 'preserve',
      module: 'esnext',
      target: 'esnext',
      ...tsConfig,
      allowJs: true,
      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;
}
  • JSDoc:

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

  • Parameters:

  • tsConfig: Record<string, unknown>
  • Return Type: ts.CompilerOptions
  • Calls:
  • window.ts.convertCompilerOptionsFromJson
  • Array.isArray
  • window.ts.getDefaultLibFileName