How to use the @bazel/typescript.format function in @bazel/typescript

To help you get started, we’ve selected a few @bazel/typescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular / packages / bazel / src / api-extractor / index.ts View on Github external
export function runMain(
    tsConfig: string, entryPoint: string, dtsBundleOut?: string, apiReviewFolder?: string,
    acceptApiUpdates = false): 1|0 {
  const [parsedConfig, errors] = parseTsconfig(tsConfig);
  if (errors && errors.length) {
    console.error(format('', errors));

    return 1;
  }

  const pkgJson = path.resolve(path.dirname(entryPoint), 'package.json');
  if (!fs.existsSync(pkgJson)) {
    fs.writeFileSync(pkgJson, JSON.stringify({
      'name': 'GENERATED-BY-BAZEL',
      'version': '0.0.0',
      'description': 'This is a dummy package.json as API Extractor always requires one.',
    }));
  }

  // API extractor doesn't always support the version of TypeScript used in the repo
  // example: at the moment it is not compatable with 3.2
  // to use the internal TypeScript we shall not create a program but rather pass a parsed tsConfig.