ClassSpawnArgs
ClassSpawnArgs<
E> = [SetupParamTuple<E>] extends [never] ? [SpawnOptions] :SetupParamTuple<E> extends readonly [] ? [SpawnOptions] : [] extendsSetupParamTuple<E> ? [SetupParams<E>,SpawnOptions] : [SetupParams<E>,SpawnOptions]
Defined in: Scene.ts:98
Trailing arguments of the class form of spawn / spawnChild, derived from
the entity’s setup() signature. An omitted required field is reported as a
missing property on the params type.
The params slot follows the setup PARAMETER, not the param object’s fields:
- no declared
setup→ only the trailing options slot. setup(): voidwith zero parameters → no params slot; behaves like a class with no declaredsetup, sospawn(Class, options?).setup(params?)or a defaulted parameter (a zero-argument call is valid, so[]is assignable to the parameter tuple) → params slot optional.setup(params)with a required parameter → params slot required, even when the param object’s own fields are all optional.setup(undefined)at runtime would break a body that readsparams, so the type demands the argument.
The zero-parameter branch (SetupParamTuple<E> extends readonly []) must
precede the optional-parameter branch: an exactly-empty tuple [] is
assignable to readonly [], while an optional-first-parameter tuple [X?]
is not, so the check catches only a genuine zero-arg setup and leaves
setup(params?) to the branch below.
The params slot is typed as SetupParams<E> alone (not
SetupParams<E> | SpawnOptions), so a SpawnOptions-shaped object is not
silently accepted where params belong. The one residual: if the param type
itself declares an optional key, a { key } literal satisfies the slot and
the runtime routes it to options — the “don’t name a top-level setup field
key” footgun documented on SpawnOptions.key. Use the explicit 3-arg form.
Type Parameters
Section titled “Type Parameters”E