escalier-lang / escalier-next

Improved type safety with tight TypeScript interop
https://escalier-lang.github.io/escalier-next/
MIT License
14 stars 0 forks source link

Refactor how enums are parsed and type-checked #313

Closed kevinbarabash closed 4 months ago

kevinbarabash commented 4 months ago

In particular, enum variants can be wrap either a tuple or an object or be empty. The variants are inferred as:

{ __TAG__: unique symbol}; // empty 
{ __TAG__: unique symbol} & [number, string]; // tuple
{ __TAG__: unique symbol} & {x: number, y: number}; // object

The __TAG__ is the unique symbol assigned to MyEnum.MyVariant.

The reason for odd variant types is that we want to support both tuple and object payloads while also support interop with TypeScript tagged unions in the future.

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 91.75824% with 15 lines in your changes missing coverage. Please review.

Project coverage is 84.79%. Comparing base (3118ee1) to head (6aef0fc).

Files Patch % Lines
src/Escalier.TypeChecker/Infer.fs 89.51% 15 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #313 +/- ## ========================================== + Coverage 84.77% 84.79% +0.01% ========================================== Files 23 23 Lines 11550 11582 +32 Branches 1592 1602 +10 ========================================== + Hits 9792 9821 +29 - Misses 1758 1761 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.