Skip to content

feat: enable TypeScript strict mode for calm-models and cli#2186

Merged
markscott-ms merged 4 commits intofinos:mainfrom
rocketstack-matt:feat/enable-strict-mode-calm-models-cli
Feb 28, 2026
Merged

feat: enable TypeScript strict mode for calm-models and cli#2186
markscott-ms merged 4 commits intofinos:mainfrom
rocketstack-matt:feat/enable-strict-mode-calm-models-cli

Conversation

@rocketstack-matt
Copy link
Member

Description

Enables "strict": true in the tsconfig for both calm-models and cli, fixing all resulting type errors. This addresses part of #1396.

calm-models fixes:

  • Make requirement-url optional in CalmFlowCanonicalModel to match the optional class field
  • Add undefined guard before calling CalmNodeDetails.fromSchema

cli fixes:

  • Replace transitive inquirer import with @inquirer/prompts (the actual declared dependency)
  • Narrow unknown catch variables with instanceof/type guards
  • Fix Logger.error calls to pass a single string argument
  • Add undefined guards for optional fields (verbose, architecturePath, patternPath, serverProcess.pid)
  • Use proper Record types for JSON object indexing in tests
  • Convert ValidationRequest from class to interface
  • Widen process.exit mock parameter type to match actual signature
  • Initialize unassigned mock variable in routes test

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Code style/formatting changes
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Test additions or updates
  • 🔧 Chore (maintenance, dependencies, CI, etc.)

Affected Components

  • CLI (cli/)
  • CALM Models
  • Shared (shared/)
  • CALM Widgets (calm-widgets/)
  • CALM Hub (calm-hub/)
  • CALM Hub UI (calm-hub-ui/)
  • Documentation (docs/)
  • VS Code Extension (calm-plugins/vscode/)
  • Dependencies
  • CI/CD

Commit Message Format ✅

Testing

  • I have tested my changes locally
  • I have added/updated unit tests
  • All existing tests pass

Checklist

  • My commits follow the conventional commit format
  • I have updated documentation if necessary
  • I have added tests for my changes (if applicable)
  • My changes follow the project's coding standards

Enables `"strict": true` in the tsconfig for both calm-models and cli,
fixing all resulting type errors. This addresses part of finos#1396.

calm-models fixes:
- Make requirement-url optional in CalmFlowCanonicalModel to match the
  optional class field
- Add undefined guard before calling CalmNodeDetails.fromSchema

cli fixes:
- Replace transitive inquirer import with @inquirer/prompts (the actual
  declared dependency)
- Narrow unknown catch variables with instanceof/type guards
- Fix Logger.error calls to pass a single string argument
- Add undefined guards for optional fields (verbose, architecturePath,
  patternPath, serverProcess.pid)
- Use proper Record types for JSON object indexing in tests
- Convert ValidationRequest from class to interface
- Widen process.exit mock parameter type to match actual signature
- Initialize unassigned mock variable in routes test
Copy link
Contributor

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 enables TypeScript strict mode for the calm-models and cli packages, addressing part of issue #1396. Strict mode adds stronger type checking that improves code quality and catches potential bugs at compile time. The changes fix all resulting type errors in both packages.

Changes:

  • Enabled "strict": true in tsconfig for calm-models and cli packages
  • Fixed type inconsistencies in calm-models (optional fields, undefined guards)
  • Updated cli to use correct imports, add proper error handling with type guards, and handle optional values correctly

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cli/tsconfig.json Enables TypeScript strict mode for the cli package
calm-models/tsconfig.build.json Enables TypeScript strict mode for calm-models package
calm-models/src/canonical/template-models.ts Makes requirement-url optional to match the CalmFlowSchema type definition
calm-models/src/model/moment.ts Adds undefined guard before calling CalmNodeDetails.fromSchema
cli/src/cli.ts Replaces transitive inquirer import with declared @inquirer/prompts dependency, adds null coalescing for optional verbose parameter
cli/src/command-helpers/validate.ts Adds error type guards, undefined handling for optional paths, and type assertions for validate function parameters
cli/src/cli-config.ts Improves error handling with proper type guards for unknown error types
cli/src/server/routes/validation-route.ts Adds error type guard and converts ValidationRequest from class to interface
cli/src/server/routes/routes.spec.ts Initializes schemaDirectory mock variable to avoid undefined errors
cli/src/command-helpers/template.spec.ts Widens process.exit mock parameter type to match Node.js signature
cli/src/cli.e2e.spec.ts Adds type annotations and guards for catch blocks, improves JSON handling with proper Record types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rocketstack-matt rocketstack-matt marked this pull request as draft February 27, 2026 17:43
…ture and pattern

The validate function already handles undefined values at runtime via
truthiness checks, but its signature declared both parameters as
non-nullable. This forced callers to use unsafe `as object` type
assertions. Update the signature to reflect the actual runtime contract
and replace the CLI's type casts with an explicit runtime guard.
@rocketstack-matt rocketstack-matt marked this pull request as ready for review February 28, 2026 16:16
@rocketstack-matt
Copy link
Member Author

This PR is ready to review @markscott-ms

@markscott-ms markscott-ms merged commit 63fd92f into finos:main Feb 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants