Packages > @fluidframework/tree > TreeNode

TreeNode Class

A non-leaf SharedTree node. Includes objects, arrays, and maps.

Signature

/** @sealed */
export declare abstract class TreeNode implements WithType

Implements: WithType

Remarks

Base type which all nodes implement.

This can be used as a type to indicate/document values which should be tree nodes. Runtime use of this class object (for example when used with instanceof or extending it), is not currently supported.

Instances of tree nodes must be created by opening an existing document, inserting values into the document, or by using the constructors and create functions of TreeNodeSchema produced by SchemaFactory .

Constructors

Constructor Description
(constructor)() Constructs a new instance of the TreeNode class

Static Methods

Method Return Type Description
[Symbol.hasInstance](value) value is TreeNode Provides instanceof support for testing if a value is a TreeNode.
[Symbol.hasInstance](this, value) value is InstanceType<TSchema> Provides instanceof support for all schema classes with public constructors.

Properties

Property Modifiers Type Description
[typeNameSymbol] readonly string Adds a type symbol for stronger typing.

Constructor Details

(constructor)

Constructs a new instance of the TreeNode class

Signature

protected constructor();

Property Details

[typeNameSymbol]

Adds a type symbol for stronger typing.

Signature

abstract get [typeNameSymbol](): string;

Type: string

Method Details

[Symbol.hasInstance]

Provides instanceof support for testing if a value is a TreeNode.

Signature

static [Symbol.hasInstance](value: unknown): value is TreeNode;

Remarks

For more options, like including leaf values or narrowing to collections of schema, use is or schema from TreeNodeApi .

Parameters

Parameter Type Description
value unknown

Returns

Return type: value is TreeNode

[Symbol.hasInstance]

Provides instanceof support for all schema classes with public constructors.

Signature

static [Symbol.hasInstance]<TSchema extends abstract new (...args: any[]) => TreeNode>(this: TSchema, value: unknown): value is InstanceType<TSchema>;
Type Parameters
Parameter Constraint Description
TSchema abstract new (...args: any[]) => TreeNode

Remarks

For more options, like including leaf values or narrowing to collections of schema, use is or schema from TreeNodeApi .

Parameters

Parameter Type Description
this TSchema
value unknown

Returns

Return type: value is InstanceType<TSchema>