Skip to content

fix: Infer parameter type from default value when no explicit type annotation#476

Merged
danadajian merged 1 commit intomainfrom
feat/infer-type-from-default-args
May 5, 2026
Merged

fix: Infer parameter type from default value when no explicit type annotation#476
danadajian merged 1 commit intomainfrom
feat/infer-type-from-default-args

Conversation

@danadajian
Copy link
Copy Markdown
Contributor

Summary

  • When a custom command parameter has a default value but no explicit TypeScript type annotation (e.g. input1 = 123), the generated interface previously emitted an untyped optional (input1?), which provided no IntelliSense benefit
  • The generator now infers number, string, or boolean from numeric, string, and boolean literals respectively, producing correctly-typed optional parameters in the generated interface
  • Parameters that already carry an explicit type annotation are unaffected — the explicit annotation always takes precedence

Changes

  • Default argument with no type annotation now resolves to a typed optional in the generated Chainable interface
  • Supported literal types: number, string, boolean

Test plan

  • export function example(input1 = 123) {} → generates example(input1?: number): Chainable
  • export function example(input1 = 'hello') {} → generates example(input1?: string): Chainable
  • export function example(input1 = true) {} → generates example(input1?: boolean): Chainable
  • Existing behaviour for explicitly-annotated defaults (e.g. input2: number = 0) is unchanged

Generated with Claude Code

…esent

When a function parameter has a default value but no explicit TypeScript
type annotation (e.g. `input1 = 123`), the generated interface now infers
the correct type from the literal (number, string, boolean) rather than
emitting an untyped optional parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@danadajian danadajian changed the title Infer parameter type from default value when no explicit type annotation fix: Infer parameter type from default value when no explicit type annotation May 5, 2026
@danadajian danadajian merged commit 5bd8046 into main May 5, 2026
4 checks passed
@danadajian danadajian deleted the feat/infer-type-from-default-args branch May 5, 2026 17:07
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

🎉 This PR is included in version 2.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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