Skip to content

Spec

module Spec
AssemblyXantham.Generator

The facts and mappings every shaping pass is written against: what a resolved type is (literal, tuple, callback, branded primitive, constructor object, tagged union), the F# reference it maps to, its declared type parameters, and shared member and signature shaping.

Declared inside

CompiledSignatureSignatures as .NET overload resolution compares them: abbreviations expanded at every depth and a signature's own type variables renamed by position

Functions and values

abbreviations (decls: FsDecl list) : Map<string,FsTypeRef>

Type abbreviations declared by a model, as name -> target. Shared by the passes that must compare signatures the way the compiler does: .NET overload resolution sees through an abbreviation, so TargetsParam and the U6<...> it abbreviates are one type to it.

bindingOf (export: HarvestedExport) : ImportBinding

How a harvested value binds in JavaScript. An ambient global is already on globalThis, so it takes [<Global>]; a module export carries an import, and an ambient module's export carries the specifier its declaration quotes.

defaultExportName (ctx: Context) : string

The fallback name for a default export - Naming.defaultExport over the entry package.

expandAbbreviations (abbrevs: Map<string,FsTypeRef>) (visited: Set<string>) (reference: FsTypeRef) : FsTypeRef

A reference with abbreviations expanded. visited breaks a cycle a malformed declaration set could otherwise spin on; it is threaded rather than global so nested positions of one reference each get their own budget.

fsName (fallback: string) (export: HarvestedExport) : string

The F# name a harvested export generates under: the exported name; a default export takes its declaring symbol's name - except export default function name binds the symbol itself as default, which falls back to the package-derived name.

hasIncompatibleOverloadedTypeParameters (model: ShapeModel) (facts: TypeFacts) : bool

An object type whose call signatures hoist a shared type-parameter name under two different bounds — the F# head produced by aliasTypeParams is unwritable.

literalOf (facts: TypeFacts) : FsLiteral option

The literal payload of a literal type, when the response carries one.

memberTypeRef (ctx: Context) (model: ShapeModel) (self: string option) (owner: string) (member_: ResolvedMember) : FsTypeRef * Finding list

Preserves direct source string-alias annotations without capturing unannotated interned unions.

nestUnder (owner: string) (segment: string) : string

The name a shape reached at segment of owner declares under: Widget and Options give Widget.Options, which render-source writes as type Options inside module Widget. The result carries a dot only where both ends take the identifier shape a module opens under; a JavaScript key like beta channel concatenates and stays one backticked name.

optionalRef (optional: bool) (reference: FsTypeRef) : FsTypeRef

An optional member or parameter reads as option, one level deep however the optionality arrived (a ? marker, an undefined union member, or both).

reservedCaseNames: Set<string>

F# identifiers a bare single-case [<StringEnum>] case collides with if written without RequireQualifiedAccess: the core library's own single-case union members.

typeParamsOf (ctx: Context) (model: ShapeModel) (owner: string) (ids: int<typeId> list) : FsTypeParam list * Map<int<typeId>,string> * Finding list

A declaration's own type parameters, and the scope its members must be shaped under. Both come from one walk so they agree: a member may reference exactly the parameters that earn a name. A constraint survives only where it maps to a named type; extends keyof T drops.

typeRef (ctx: Context) (model: ShapeModel) (self: string option) (owner: string) (typeId: int<typeId>) : FsTypeRef * Finding list

The F# type written at a reference position, with the findings any widening produces. self is the name of the declaration being shaped, so a polymorphic this return resolves to it. A type carries several flags at once, so the arm order below picks which finding.

typeScriptLiteral (literal: FsLiteral) : string

The TypeScript spelling of a literal: 2, 0.5, "method".

uniqueCaseNames (names: string list) : string list

Case names must be unique within one DU; a later duplicate takes a numeric suffix in member order, deterministically.