feat: enable TypeScript strict mode for calm-models and cli#2186
Merged
markscott-ms merged 4 commits intofinos:mainfrom Feb 28, 2026
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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": truein 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.
…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.
Member
Author
|
This PR is ready to review @markscott-ms |
3 tasks
markscott-ms
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Enables
"strict": truein the tsconfig for both calm-models and cli, fixing all resulting type errors. This addresses part of #1396.calm-models fixes:
cli fixes:
Type of Change
Affected Components
cli/)shared/)calm-widgets/)calm-hub/)calm-hub-ui/)docs/)calm-plugins/vscode/)Commit Message Format ✅
Testing
Checklist