Skip to content

Improve Type Safety in Utility Modules#7925

Draft
serhalp wants to merge 8 commits intomainfrom
improve-type-safety-utils-10752538661482729364
Draft

Improve Type Safety in Utility Modules#7925
serhalp wants to merge 8 commits intomainfrom
improve-type-safety-utils-10752538661482729364

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Feb 3, 2026

This submission improves type safety in several utility modules (leaf nodes) by resolving @ts-expect-error directives, implicit any types, and unsafe property access. Key changes include:

  • src/utils/dot-env.ts: Defined DotEnvResult types and used type predicates for safe filtering.
  • src/utils/dev.ts: Added types to getDotEnvVariables and other helpers, resolving unused @ts-expect-error tags.
  • src/utils/telemetry/report-error.ts: Integrated @bugsnag/js types for NotifiableError and Event.
  • src/utils/command-helpers.ts: Added a type guard for errors in pollForToken.
  • src/utils/types.ts: Updated EnvironmentVariableSource to support custom string sources while maintaining literal autocompletion.
  • src/lib/build.ts: Expanded CachedConfig to include missing envFiles and env_files properties.

PR created automatically by Jules for task 10752538661482729364 started by @serhalp

- Improved type safety in `src/utils/dot-env.ts` by adding explicit types and type predicates.
- Resolved multiple `@ts-expect-error` directives in `src/utils/dev.ts` by typing parameters and handling optional properties.
- Enhanced `src/utils/telemetry/report-error.ts` with types from `@bugsnag/js` and safer error handling.
- Fixed a `catch` block error in `src/utils/command-helpers.ts` with a type guard.
- Updated `src/utils/types.ts` and `src/lib/build.ts` to support stricter environment variable and configuration types.
- Verified changes with `npm run typecheck` and unit tests.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
@serhalp serhalp requested a review from a team as a code owner February 3, 2026 16:32
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

📊 Benchmark results

Comparing with 827d71a

  • Dependency count: 1,070 (no change)
  • Package size: 320 MB (no change)
  • Number of ts-expect-error directives: 345 ⬇️ 5.80% decrease vs. 827d71a

@serhalp serhalp marked this pull request as draft February 3, 2026 16:36
google-labs-jules bot and others added 7 commits February 3, 2026 16:37
- Improved type safety in `src/utils/dot-env.ts` by adding explicit types and type predicates.
- Resolved multiple `@ts-expect-error` directives in `src/utils/dev.ts` by typing parameters and handling optional properties safely.
- Enhanced `src/utils/telemetry/report-error.ts` with types from `@bugsnag/js` and safer error handling.
- Fixed a `catch` block error in `src/utils/command-helpers.ts` with a type guard.
- Updated `src/utils/types.ts` and `src/lib/build.ts` to support stricter environment variable and configuration types.
- Fixed ESLint errors including misused promises, unnecessary conditions, and base-to-string conversions.
- Verified changes with `npm run typecheck`, `npm run lint`, and unit tests.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
- Improved type safety in `src/utils/dot-env.ts` by adding explicit types and type predicates.
- Resolved multiple `@ts-expect-error` directives in `src/utils/dev.ts` by typing parameters and handling optional properties safely.
- Enhanced `src/utils/telemetry/report-error.ts` with types from `@bugsnag/js` and safer error handling.
- Fixed a `catch` block error in `src/utils/command-helpers.ts` with a type guard.
- Updated `src/utils/types.ts` and `src/lib/build.ts` to support stricter environment variable and configuration types.
- Fixed ESLint errors including misused promises, unnecessary conditions, and base-to-string conversions.
- Ensured code is formatted with Prettier.
- Verified changes with `npm run typecheck`, `npm run lint`, and unit tests.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
- Improved type safety in `src/utils/dot-env.ts` with explicit types and type predicates.
- Resolved `@ts-expect-error` directives in `src/utils/dev.ts` and handled optional properties.
- Enhanced `src/utils/telemetry/report-error.ts` with types from `@bugsnag/js`.
- Fixed error handling in `src/utils/command-helpers.ts` with type guards.
- Updated `src/utils/types.ts` and `src/lib/build.ts` for consistency.
- Resolved several ESLint and formatting issues.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
- Improved type safety in `src/utils/dot-env.ts` with explicit types and type predicates.
- Enhanced robustness in `src/utils/dev.ts` with fallbacks for site information and account IDs.
- Integrated `@bugsnag/js` types in `src/utils/telemetry/report-error.ts`.
- Added type guards in `src/utils/command-helpers.ts` for error handling.
- Resolved ESLint and formatting issues.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
- Improved type safety in `src/utils/dot-env.ts` by defining proper result types and using type predicates.
- Refactored `src/utils/telemetry/report-error.ts` to use `unknown` for errors and properly normalize them into `Error` objects.
- Resolved `@ts-expect-error` in `src/utils/command-helpers.ts` with a type guard.
- Added explicit types to multiple functions in `src/utils/dev.ts` and improved robustness by handling missing `site.root`.
- Updated `EnvironmentVariableSource` in `src/utils/types.ts` to allow custom sources while maintaining autocompletion.
- Fixed numerous `@ts-expect-error` directives and implicit `any` across the modified files.
- Ensured all changes pass type checking, linting, and relevant integration tests.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
- Improved type safety in `src/utils/dot-env.ts` by defining proper result types and using type predicates.
- Refactored `src/utils/telemetry/report-error.ts` to use `unknown` for errors and properly normalize them into `Error` objects.
- Resolved `@ts-expect-error` in `src/utils/command-helpers.ts` with a type guard.
- Added explicit types to multiple functions in `src/utils/dev.ts` and improved robustness by handling missing `site.root`.
- Updated `EnvironmentVariableSource` in `src/utils/types.ts` to allow custom sources while maintaining autocompletion.
- Fixed numerous `@ts-expect-error` directives and implicit `any` across the modified files.
- Ensured all changes pass type checking, linting, formatting and relevant integration tests.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
- Improved type safety in `src/utils/dot-env.ts` by defining proper result types and using type predicates.
- Refactored `src/utils/telemetry/report-error.ts` to use `unknown` for errors and properly normalize them into `Error` objects, with robustness against circularity.
- Resolved `@ts-expect-error` in `src/utils/command-helpers.ts` with a type guard.
- Added explicit types to multiple functions in `src/utils/dev.ts` and improved robustness by handling missing `site.root` (CWD fallback) and `site.id`.
- Updated `EnvironmentVariableSource` in `src/utils/types.ts` to allow custom sources while maintaining autocompletion.
- Fixed numerous `@ts-expect-error` directives and implicit `any` across the modified files.
- Ensured `processOnExit` safely handles async handlers without misused-promises lint errors.
- Ensured all changes pass type checking, linting, formatting and relevant unit tests.

Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant