8000 feat: TypeScript target · Issue #20 · Mnehmos/mnehmos.nls.lang · GitHub
[go: up one dir, main page]

Skip to content

feat: TypeScript target #20

Closed
Closed

Description

@Mnehmos

Overview

Emit TypeScript code from .nl files.

Command

nlsc compile src/math.nl --target typescript
✓ Generated src/math.ts (42 lines)

Implementation

  • Add emit_typescript() in emitter.py
  • Map NLS types → TS types (number→number, string→string, etc.)
  • Generate interfaces from @type blocks
  • Generate typed functions from ANLUs
  • Handle guards as type guards or runtime checks

Type Mapping

NLS TypeScript
number number
string string
boolean boolean
list of X X[]
CustomType interface CustomType

Exit Criteria

  • Generated TypeScript compiles with tsc --strict
  • Type safety matches NLS constraints

Activity

  1. Mnehmos commented on Jan 18, 2026

    @Mnehmos
    OwnerAuthor

    Updated Roadmap Context

  2. Mnehmos commented on Sep 12, 2026

    @Mnehmos
    OwnerAuthor

    Audited against current master — the TypeScript target is fully delivered and exceeds the original exit criteria:

    • Emitter: nlsc/emitter_typescript.py implements emit_typescript() and generates interfaces from @type blocks, typed functions from ANLUs, guards as runtime checks with portable error classes, invariants and constraints as validating make_<Type> factories, and tests from @test blocks.
    • Type mapping: exactly as specified in this issue (number/string/boolean, list of X → X[], custom types → interfaces).
    • Exit criteria: generated TypeScript compiles under tsc --strict in the required CI job (typescript-conformance), and type safety matches NLS constraints — the cross-target semantic suite executes the same fixtures on Python and Node and compares values, normalized failures, and error identities.
    • Beyond the original scope: an NLS runtime (structural equality, NLS truthiness, Python-compatible division/modulo), capability-matrix enforcement (ETARGET002 refuses content the target cannot represent), and IR-based expression rendering shared with the Python backend.

    Closing as delivered; the remaining per-target migration work (fully consuming checked IR) stays tracked under #202.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    emitterCode generation targetsenhancementNew feature or requestmulti-targetCross-platform compilation

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0