Changes
This release fixes some edge case with MoonScript object type detection false positives. It also fixes issues when trying to write tableshape shapes that match tableshape types. You can now write transformers to transform tableshape types into something else (see json_schema)
New extension modules
- Add
tableshape.ext.json_schema- convert tableshape type definitions into JSON Schema objects. SupportsShape,ArrayOf,OneOf,Range,Pattern, literal types, optional types, and more. Includes aJsonSchemawrapper type for overriding generated schemas with custom JSON Schema. See https://github.com/leafo/tableshape/blob/master/tableshape/ext/json_schema.md - Add
tableshape.ext.with_args- Helper function to wrap a Lua function with tableshape type validation performed on the arguments before the function is called. Supports positional argument types, aresttype for variadic args, and anassertoption to throw errors instead of returningnil, err. See https://github.com/leafo/tableshape/blob/master/tableshape/ext/with_args.md - Add
tableshape.ext.luassert- luassert integration module. Registers ashapeassertion and a formatter for tableshape types
Core improvements
- Fix
Proxyrecursion in_describe- proxy types that reference themselves no longer cause infinite loops when described - Improve
is_base_typedetection - correctly rejects MoonScript__baseprototype tables that were previously misidentified as type checker instances - Improve
describe_typefor__basetables - uses the class name instead of triggering__tostring, which could cause a hard error - Export additional types from
typestable -describe,optional, and internal node types (_transform,_tagged_type,_tag_scope_type,_sequence,_first_of)
MoonScript module fixes
class_type- rewrite validation to be more correct, check for__baseand constructor viarawgetwith clearer error messagesinstance_type- rewrite to be more correct, verify metatable conventions and reject__baseobjects, preventing false positives
Full Changelog: v2.6.0...v2.7.0