ts-repo-utils
    Preparing search index...

    Function checkShouldRunTypeChecks

    • Checks if TypeScript type checks should run based on the diff from a base branch. Skips type checks if all changed files match the ignored patterns.

      This function is typically used in CI/CD pipelines to determine whether expensive type checking operations should be performed. If all changed files are documentation, configuration, or other non-TypeScript files, type checks can be safely skipped to improve build performance.

      Parameters

      • Optionaloptions: Readonly<{ baseBranch?: string; pathsIgnore?: readonly string[] }>

        Configuration options

        • pathsIgnore

          Array of patterns to ignore when determining if type checks should run. Supports three pattern types:

          • Exact file matches: e.g., .cspell.config.yaml matches only that file
          • Directory prefixes: e.g., docs/ matches any file in docs directory
          • File extensions: e.g., **.md matches any markdown file Defaults to: ['LICENSE', '.editorconfig', '.gitignore', '.cspell.json', '.cspell.config.yaml', '.markdownlint-cli2.mjs', '.npmignore', '.prettierignore', '.prettierrc', 'docs/', '**.md', '**.txt']
        • baseBranch

          Base branch to compare against for determining changed files. Defaults to 'origin/main'

      Returns Promise<boolean>

      A promise that resolves when the check is complete. The function will set the GITHUB_OUTPUT environment variable with should_run=true or should_run=false if running in GitHub Actions environment.

        // Use default settings (compare against origin/main, ignore docs/md/txt files)
      await checkShouldRunTypeChecks();

      // Custom ignore patterns
      await checkShouldRunTypeChecks({
      pathsIgnore: ['.eslintrc.json', 'docs/', '**.md', 'scripts/'],
      });

      // Custom base branch
      await checkShouldRunTypeChecks({
      baseBranch: 'origin/develop',
      });

      GitHub Actions usage

      - name: Check if type checks should run
      id: check_diff
      run: npm exec check-should-run-type-checks

      - name: Run type checks
      if: steps.check_diff.outputs.should_run == 'true'
      run: npm run type-check