Skip to content

OutputSymbol

An output symbol is a named entity that can be referenced in your output code.

__v_skipboolean
[inspect.custom]() => string
constructor(name: string | Namekey, spaces: OutputSpace[] | OutputSpace | undefined, options: OutputSymbolOptions)Constructs a new instance of the OutputSymbol class
aliasTargetOutputSymbol | undefinedThe symbol that this symbol is an alias for.
binderBinder | undefinedThe binder that is tracking this symbol.
copy() => OutputSymbolCreate a clone of this symbol whose name and flags reactively track the original.
copyMembersTo(targetSymbol: OutputSymbol) => voidCopy the members of this symbol to the target symbol. This is reactive - whenever a member is added to this symbol, it will be copied to the target symbol.
copyToSpace(space: OutputSpace) => OutputSymbolCopy this symbol into the given space. Calls [unresolved link] and places the result in space, then returns the copy.
dealias() => OutputSymbolIf this symbol is an alias for another symbol, return the the aliased symbol. Otherwise, return this symbol.
debugInfoRecord<string, unknown>
delete() => void
protected getCopyOptions() => { binder: Binder | undefined; aliasTarget: OutputSymbol | undefined; metadata: Record<string, unknown>; transient: boolean; }
hasTypeSymbolbooleanWhether this symbol has its symbol representing its type available.
idnumberThe unique id of this symbol.
ignoreNameConflictbooleanWhether the name of this symbol bypasses the active name conflict resolution. When true, the name of this symbol will be fixed, though it may conflict with other symbols which are also ignoring name conflict resolution.
ignoreNamePolicybooleanWhether the name of this symbol bypasses the active name policy. When true, the name of this symbol will be fixed, though it may conflict with other symbols which are also ignoring the name policy.
protected initializeCopy(copy: OutputSymbol) => voidWires up reactive member-space copying and name tracking from this symbol to its copy.
isAliasbooleanWhether this symbol is an alias for another symbol.
isMemberSymbolbooleanWhether this symbol is a member of another symbol.
isMovedbooleanWhether this symbol’s members have been moved to another symbol.
isTransientbooleanWhether this symbol is a transient symbol. Transient symbols cannot be referenced and are meant to be combined with other symbols.
isTypedbooleanWhether this symbol’s members are provided by a type symbol. The typeSymbol property is this symbol. It may not be available yet, so check hasTypeSymbol.
memberSpaceFor(spaceKey: string) => OutputMemberSpace | undefinedGet the member space for the given key.
memberSpacesOutputMemberSpace[]The member spaces of this symbol.
memberSpacesReadonly<string[]>The member space keys for this symbol type. Subclasses override this to declare which member spaces are created on construction (e.g., ["static", "instance"]).
metadataRecord<string, unknown>An arbitrary bag of metadata for this symbol. This property is read only, but the metadata is a reactive object.
movedToOutputSymbol | undefinedThe symbol that this symbol’s members have been moved to.
moveMembersTo(targetSymbol: OutputSymbol) => voidMove member symbols from this transient symbol to the target symbol. This is reactive - whenever a member is added to this symbol, it will be moved to the target symbol.
namestringThe name of this symbol. Assigning to this property applies the active name policy (unless ignoreNamePolicy is true) before storing the value.
namePolicyNamePolicyGetter | undefined
originalNamestringRead only. The requested name of this symbol. The symbol’s actual name may be different depending on naming policy or conflicts with other symbols.
ownerSymbolOutputSymbol | undefinedWhen this is a member symbol, this returns the symbol that this is symbol is a member of.
refkeysRefkey[]The refkeys for this symbol.
resolveMemberByName(name: string) => OutputSymbol | undefinedGet a member symbol by name from this symbol’s member spaces. Checks member spaces in order until it finds a member with that name.
scopeimport(”./output-scope.js”).OutputScope | undefinedThe scope this symbol is in. When this symbol is a member symbol, this will return undefined.
spacesOutputSpace[]The declaration or member spaces this symbol belongs to.
toString() => string
typeOutputSymbol | undefinedThe symbol which defines the type of this symbol. The type symbol provides information about the value this symbol contains, such as what members it has.

This is an abstract base class. Language packages must subclass it and implement the abstract copy() method, which creates a clone that tracks the original’s name and flags.

Subtypes typically add language-specific properties (e.g., accessibility, static/abstract flags). Symbols are reactive values, so you can observe changes to their properties in a reactive context.

To construct a scopeless external library symbol — one that resolves via refkey but does not appear in any declaration space — pass undefined as the spaces constructor argument and supply { binder } in options. See OutputSymbolOptions (binder option) and TO_SYMBOL.

import { createSymbol, OutputSymbol, OutputSpace } from "@alloy-js/core";

class MySymbol extends OutputSymbol {
  copy() {
    // getCopyOptions() already includes binder
    const opts = this.getCopyOptions();
    const sym = createSymbol(MySymbol, this.name, undefined, opts);
    this.initializeCopy(sym);
    return sym;
  }
}

// name: string | Namekey; spaces: OutputSpace | OutputSpace[] | undefined; options: OutputSymbolOptions
const sym = createSymbol(MySymbol, namekey, scope.symbols, { binder });

// Construct a scopeless external library symbol (resolves via refkey only):
const extSym = createSymbol(MySymbol, namekey, undefined, { binder });