Skip to content

PR7: [breaking] emit unknown for return types tywrap can't resolve #267

Description

@bbopen

Emit unknown for return types tywrap can't resolve, instead of a bare, undeclared TypeScript name. Breaking change — there will be more unknown in generated output, and --fail-on-warn builds may newly fail, which is the intent.

Today a return type whose class isn't in the analyzed module is emitted as a bare leaf name (for example Module) that nothing declares. That should be unknown, with a build-time note.

What changes

  • tywrap_ir/tywrap_ir/ir.py — keep the full dotted path (or an explicit out-of-module marker) instead of reducing <class 'mod.Name'> to Name, and record a warning when a return resolves out-of-module or unannotated. This changes the IR schema; the version bump lands in PR9: [breaking] pinned IR contract artifact + TS/Python IR-version check #269.
  • src/core/mapper.ts — carry the module through so the generator can tell in-module from out-of-module. This PR owns the degrade-to-unknown rule.
  • src/core/generator.ts — emit a type name only when it's locally declared or backed by a codec; otherwise emit unknown and call a degrade hook. Base the "keep typed" set on the types that actually round-trip through a codec — verify against the codec set (for example, numpy arrays go through the marker path, not the preset table).
  • src/tywrap.ts — wire the degrade hook into the existing unknown-type reporting so --fail-on-warn covers the generated-types path.

Done when

A third-party return emits unknown, codec-backed types keep their mapped type, and degrades show up in the generation report.

Depends on: #266.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions