Skip to content

Roadmap: Dartify Beta — Stabilization, JS Interop Migration & Runtime Validation #1

@codewithsam110g

Description

@codewithsam110g

Roadmap: Dartify Beta — Stabilization, JS Interop Migration & Runtime Validation

This issue tracks the tasks, bugs, and enhancements required to reach the first stable Beta release of dartify, the .d.ts to Dart js_interop code generator.

Goals

  • Ensure type-safe, runtime-usable Dart bindings for major .d.ts files
  • Migrate fully to dart:js_interop modern model
  • Verify real-world integration with libraries like H3, Leaflet, Axios

Core Tasks

Type System & Parser

  • Revamp typeResolver to return a fully structured IR (e.g., with typeRef, get/set, modifiers, etc)
  • Fix unions with T | undefined | null or T | null results in T not T?
  • Handle intersection types properly (A & B)
  • Fix type alias mapping (ensure type keyword is correctly tracked)
  • Handle Generics Properly
  • Implement a proper type registry and use it
  • Fix type issue where Index Signature.index type results as Object object. for example: [key: string]: int as [key: Object object]: double
  • Properly Parse Complex and Named tuple types
  • Parse Modifiers and return them, related to first one
  • Use ts.Node rather than ts.Type for parse to get more information to resolve type to string(ParsedType Interface, check first one)
  • Inbuilt Interface in js/ts are not resolved and returns just their Identifier name. for example Promise & Array
  • Emit new JSx types from js_interop. for example: JSAny, JSObject, JSString, etc.

Code Generation

  • Add @JS(...) annotations everywhere needed (with correct prefixes)
  • Escape Dart keywords (e.g., default, factory, new, etc.)
  • Convert function/constructor overloads into uniquely named external factory/methods by using a map<string, parsedFuncion[]>
  • Implement callable interfaces (deferred)
  • Correctly emit optional parameters and variadic/rest parameters (?, ...)
  • Proper operator []/[]= support for index signatures
  • Implement Interfaces with raw quoted properties as Index Signatures and then add proper get/set accessors
  • If enums dont explicitly mention the value like v1 = 0, then the result type is just the identifier not num/double
  • Hook dom/es types, classes and functions using package: web and js_interop
  • Treat ObjectLiteral Types as Classes and emit get/set acessors instead of simple Map<String, dynamic>
  • Emit JSDoc Comments to final output
  • Preserve Statement/Member in module/class/interface
  • Emit New js_interop code rather than old js code

Project Structure

  • Split monolithic emitter into per-component files (type, class, interface, etc)
  • Generate per-module files with part and export structure
  • Add a logger + debug tracer (optional)

Testing & Validation

  • Real-world test with h3-js
  • Run web integration test with leaflet
  • Run web integration test with axios
  • Test lib.dom.d.ts runtime output
  • Check output for compile-time errors (missing types, bad keywords, etc)
  • Validate correct resolution of top-level declare vars/functions

Output Formats

  • Add ability to export IR for debugging

Docs & Meta

  • Add README with usage guide
  • Add CLI usage example
  • Document annotation logic and mapping rules

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions