Skip to content

Conversation

antongolub
Copy link
Collaborator

  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub antongolub added the bug label Jul 23, 2025
@antongolub antongolub requested a review from Copilot July 23, 2025 20:22
Copilot

This comment was marked as outdated.

@antongolub antongolub requested review from Copilot and antonmedv July 23, 2025 20:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR strengthens the Options interface by converting it from an interface with optional properties to a more type-safe structure using Partial<> and introducing new helper types for better type safety and code organization.

  • Restructures the Options interface to use Partial<> wrapper for all properties
  • Introduces new type definitions (Defaults, NormalizedOpts, Snapshot) for better type organization
  • Adds explicit type annotations to function parameters that previously relied on default values

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/core.ts Refactors Options interface structure, adds new type definitions, and improves type safety with explicit parameter typing
build/core.cjs Updates compiled JavaScript to reflect parameter name changes from the TypeScript refactor
.size-limit.json Adjusts bundle size limits to accommodate the type system changes


// prettier-ignore
interface Defaults
extends Required<Omit<Options, 'ac' | 'cmd' | 'cwd' | 'prefix' | 'postfix' | 'delimiter' | 'halt' | 'input' | 'quote' | 'signal' | 'store' | 'timeout'>> {
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Defaults interface excludes 'quote' from the Required wrapper but 'quote' is included in the defaults object at line 144. This inconsistency could lead to type errors where 'quote' is expected to be always present in defaults but typed as optional.

Suggested change
extends Required<Omit<Options, 'ac' | 'cmd' | 'cwd' | 'prefix' | 'postfix' | 'delimiter' | 'halt' | 'input' | 'quote' | 'signal' | 'store' | 'timeout'>> {
extends Required<Omit<Options, 'ac' | 'cmd' | 'cwd' | 'prefix' | 'postfix' | 'delimiter' | 'halt' | 'input' | 'signal' | 'store' | 'timeout'>> {
quote: typeof quote

Copilot uses AI. Check for mistakes.

// prettier-ignore
export interface Shell<
S = false,
R = S extends true ? ProcessOutput : ProcessPromise,
> {
(pieces: TemplateStringsArray, ...args: any[]): R
<O extends Partial<Options> = Partial<Options>, R = O extends { sync: true } ? Shell<true> : Shell>(opts: O): R
<O extends Options = Options, R = O extends { sync: true } ? Shell<true> : Shell>(opts: O): R
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing from Partial<Options> to Options makes the type constraint more restrictive. Since Options is now Partial<{...}>, users may be required to provide properties that were previously optional, potentially breaking existing code.

Suggested change
<O extends Options = Options, R = O extends { sync: true } ? Shell<true> : Shell>(opts: O): R
<O extends Partial<Options> = Partial<Options>, R = O extends { sync: true } ? Shell<true> : Shell>(opts: O): R

Copilot uses AI. Check for mistakes.

sync: {
(pieces: TemplateStringsArray, ...args: any[]): ProcessOutput
(opts: Partial<Omit<Options, 'sync'>>): Shell<true>
(opts: Omit<Options, 'sync'>): Shell<true>
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing Partial<> wrapper from Omit<Options, 'sync'> makes this parameter less flexible. Since Options properties are now all optional via Partial<>, this change may require users to provide more properties than necessary for the sync shell.

Suggested change
(opts: Omit<Options, 'sync'>): Shell<true>
(opts: Partial<Omit<Options, 'sync'>>): Shell<true>

Copilot uses AI. Check for mistakes.

@antongolub antongolub removed the request for review from antonmedv July 23, 2025 20:40
@antongolub antongolub marked this pull request as draft July 23, 2025 20:40
@antongolub
Copy link
Collaborator Author

Superseded by other refactorings

@antongolub antongolub closed this Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant