Skip to content

Interop Gen: Support Complex Literal Type ExpressionsΒ #465

Open

Description

@nikeokoronkwo

This issue is for adding support to the TS Declaration Generator for additional literal type kinds such as:

  • prefix unary expressions: -1
  • binary expressions: 1+2
  • others

This is meant for expressions containing a combination of these expressions, particularly

Activity

  1. sagar-h007 commented on Jan 10, 2026

    @sagar-h007
    Contributor

    Hi @nikeokoronkwo I’d like to work on this issue.
    My plan is to extend the interop_gen transformer to handle additional TypeScript literal type expressions, such as prefix unary literals (-1, +5) and simple constant expressions (1 + 2). I’ll build on the existing literal handling, keep the scope limited to constant cases, and generate equivalent Dart literals where it’s safe.

    For anything that can’t be resolved safely, I’ll fall back to a conservative Dart type instead of failing. I’ll also add focused tests and make sure existing behavior stays unchanged.

    Please let me know if this approach works β€” happy to adjust if needed.

  2. nikeokoronkwo commented on Jan 11, 2026

    @nikeokoronkwo
    CollaboratorAuthor

    Hey @sagar-h007. Thanks for your interest!

    I don't think it may need to be limited to constant cases only. I haven't looked much into this, but as long as the type checker can resolve it to a given type, then I think it checks out as a default. IIRC if it is just one literal type at the moment it resolves to its underlying type in Dart.

    You can go ahead and get started and let me know how it looks!

  3. linked a pull request that will close this issueInterop gen additional literal types #503on Jan 12, 2026
  4. nikeokoronkwo commented on Jan 17, 2026

    @nikeokoronkwo
    CollaboratorAuthor

    This wasn't fixed yet in #503, so will reopen

  5. Varadraj75 commented on Feb 1, 2026

    @Varadraj75

    Hey @nikeokoronkwo ,
    I tested this on the current main branch and the existing literal_test passes (including unary numeric literals like -1 resolved via the type checker).
    Is there a specific remaining case or scenario that is still not handled and that this issue is intended to track?

  6. sagar-h007 commented on Feb 4, 2026

    @sagar-h007
    Contributor

    @Varadraj75 I don’t see a specific remaining case this issue is meant to track. More complex expressions such as binary or computed literals (1 + 2, 1 << 16) aren’t handled.

  7. Varadraj75 commented on Feb 5, 2026

    @Varadraj75

    Thanks for the clarification, @sagar-h007.

    From testing on main, unary literal cases (e.g. -1) already work via the type checker and existing tests pass.

    If this issue is meant to track support for computed/binary literal expressions (like 1 + 2, 1 << 16), could we clarify that explicitly? Otherwise, it seems the original scope may already be covered.

    @nikeokoronkwo β€” please confirm whether this should remain open for computed literals or be closed and tracked separately.

  8. nikeokoronkwo commented on Feb 6, 2026

    @nikeokoronkwo
    CollaboratorAuthor

    Hey @nikeokoronkwo , I tested this on the current main branch and the existing literal_test passes (including unary numeric literals like -1 resolved via the type checker). Is there a specific remaining case or scenario that is still not handled and that this issue is intended to track?

    The case for computed literals is not completed: not many changes were done concerning the addition of features to the generator in #503 and so it was more of a refactor.

  9. changed the title [-]Interop Gen: Support Additional Literal Types[/-] [+]Interop Gen: Support Complex Literal Type Expressions[/+] on Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions