Skip to content

v2.7.0

Latest

Choose a tag to compare

@leafo leafo released this 16 Mar 22:17
· 4 commits to master since this release

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. Supports Shape, ArrayOf, OneOf, Range, Pattern, literal types, optional types, and more. Includes a JsonSchema wrapper 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, a rest type for variadic args, and an assert option to throw errors instead of returning nil, err. See https://github.com/leafo/tableshape/blob/master/tableshape/ext/with_args.md
  • Add tableshape.ext.luassert - luassert integration module. Registers a shape assertion and a formatter for tableshape types

Core improvements

  • Fix Proxy recursion in _describe - proxy types that reference themselves no longer cause infinite loops when described
  • Improve is_base_type detection - correctly rejects MoonScript __base prototype tables that were previously misidentified as type checker instances
  • Improve describe_type for __base tables - uses the class name instead of triggering __tostring, which could cause a hard error
  • Export additional types from types table - 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 __base and constructor via rawget with clearer error messages
  • instance_type- rewrite to be more correct, verify metatable conventions and reject __base objects, preventing false positives

Full Changelog: v2.6.0...v2.7.0