Skip to content

fix: avoid throwing in warn mode for invalid types#283

Open
robinchen0127-star wants to merge 1 commit intogajus:masterfrom
robinchen0127-star:fix/issue-113-warn-shape
Open

fix: avoid throwing in warn mode for invalid types#283
robinchen0127-star wants to merge 1 commit intogajus:masterfrom
robinchen0127-star:fix/issue-113-warn-shape

Conversation

@robinchen0127-star
Copy link
Copy Markdown

Problem Summary

warn: true still throws for invalid $Shape(...) constructions because $ShapeType.errors() raises an invariant instead of yielding a validation error. That makes t.check() / t.warn() escape instead of logging a warning.

Solution Approach

  • replace the $ShapeType.errors() invariant with a yielded validation error tuple
  • keep assert behavior intact by covering the same invalid construction under assert mode
  • add a regression test proving warn mode logs instead of throwing

Test Evidence

cd packages/flow-runtime
npx mocha --grep "warn instead|assert mode"
# 2 passing

npx mocha
# 170 passing

Closes #113

@robinchen0127-star
Copy link
Copy Markdown
Author

Quick follow-up: this PR is ready for review.

It keeps assert-mode behavior intact, replaces the warn-mode throw with a validation error, and includes the regression coverage noted in the PR body. Local targeted and full mocha runs passed on my side.

Happy to adjust anything if you'd like the fix narrowed further.

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.

Errors are sometimes thrown with "warn" option

1 participant