jac-types

Explains Jac type annotations, casts, generics, and type-check error fixes.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-types-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-types
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-types
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-types-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing typed Jac code fails when annotations are missing, any values leak into typed destinations, or the checker rejects valid-looking generics. This Skill provides the verified rules for Jac's type system so you can write code that passes jac check on the first attempt and diagnose type errors quickly. ## Core Features & Use Cases - Annotation rules: Covers required parameter and return types, has field typing, union and optional types (X | None), and inference inside function bodies. - Boundary handling: Documents the as cast escape hatch, the three-step playbook for any values from Python interop or walker reports, and import type for breaking circular imports. - Error diagnosis: Maps common checker errors (E1001, E1030, E1032, E2004, W1037) to concrete fixes, including generics traps and the Self return caveat. - Use Case: You call an untyped Python library from Jac and get E1002 when assigning the result to a typed field. This Skill tells you to type the source, accept-and-narrow with isinstance, or cast at the use site. ## Quick Start Load the jac-types skill and explain why my Jac function fails jac check with error E1001 when assigning a walker report to a typed list field.

Frequently Asked Questions about jac-types

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix E1001 cannot assign type errors in Jac?

E1001 means the right-hand side type does not match the declared destination type. Widen the declared type, narrow the value with an isinstance check, or apply an `as` cast at the boundary when you know the runtime shape.

How do I handle any values from Python calls in Jac?

Follow the three-step playbook: type the source with a return annotation or stub, accept the value into an inferred local and narrow with isinstance, or cast at the use site with `value as Type`. Do not annotate everything as `any`, which only defers the error.

Does Jac support generics and type parameters?

Yes, Jac supports declared type parameters like `obj Result[T, E = Exception]` and `def first[T](items: list[T]) -> T`. However, type-param defaults do not apply at subscripted construction, and the checker treats `T` opaquely, so cast results back to concrete types.

Should I use Optional or Union types in Jac annotations?

No, use Jac-native syntax instead. Write `X | None` instead of `Optional[X]` and `X | Y` instead of `Union[X, Y]`. Use lowercase built-ins like `list[X]` rather than `List[X]`, and the `any` keyword rather than importing `Any` from typing.

Why does my Jac code fail with E1032 Type is Unknown?

E1032 means type inference failed, often from an unresolved import or a `-> Self` return annotation, which the current checker resolves to Unknown. Add an explicit annotation or return the concrete archetype name instead of `Self`.

When should I use import type instead of import in Jac?

Use `import type` to break circular imports between modules whose types reference each other, since it compiles to a TYPE_CHECKING-guarded import. Do not use it for names you construct, isinstance-check, or use in `has` field types, because the name does not exist at runtime.