Skip to main content

TreeRecordNode Interface

A TreeNode which models a TypeScript record.

This API is provided as a beta preview and may change without notice.

To use, import via @fluidframework/tree/beta.

For more information about our API support guarantees, see here.

Signature

export interface TreeRecordNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeNode, Record<string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>>

Extends: TreeNode, Record<string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>>

Type Parameters

Parameter Constraint Default Description
TAllowedTypes ImplicitAllowedTypes ImplicitAllowedTypes

Remarks

Due to https://github.com/microsoft/TypeScript/issues/43826, we can't enable implicit construction of TreeNodes for setters. Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method, or using some other method like create(schema, data).

Field Assignment and Deletion

Unlike JavaScript's Record type, assigning undefined to a key in TreeRecordNode behaves like a delete operation, removing the field's contents.

This is to stay consistent with TreeObjectNode behavior.

Example:

const Numbers = schemaFactory.record("Numbers", schemaFactory.number);
const record = new Numbers({ a:1, b:2 });

// This is equivalent to delete record.a, and removes the entry.
record.a = undefined

Methods

Method Alerts Return Type Description
[Symbol.iterator]() Beta IterableIterator<[ string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes> ]> Allows the record's entries to be iterated over, including in contexts like for...of loops.

Method Details

[Symbol.iterator]

Allows the record's entries to be iterated over, including in contexts like for...of loops.

This API is provided as a beta preview and may change without notice.

For more information about our API support guarantees, see here.

Signature
[Symbol.iterator](): IterableIterator<[
string,
TreeNodeFromImplicitAllowedTypes<TAllowedTypes>
]>;

Returns

Return type: IterableIterator<[ string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes> ]>