TreeNode Class

Packages > @fluidframework/tree > TreeNode

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)(token) TreeNodes must extend schema classes created by SchemaFactory, and therefore this constructor should not be invoked directly by code outside this package.

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 Alerts Modifiers Type Description
[typeNameSymbol] Deprecated readonly string Adds a type symbol for stronger typing.
[typeSchemaSymbol] readonly TreeNodeSchemaClass Adds a type symbol for stronger typing.

Constructor Details

(constructor)

TreeNodes must extend schema classes created by SchemaFactory, and therefore this constructor should not be invoked directly by code outside this package.

Signature

protected constructor(token: unknown);

Parameters

Parameter Type Description
token unknown

Property Details

[typeNameSymbol]

Adds a type symbol for stronger typing.

This API is deprecated and will be removed in a future release.

Use typeSchemaSymbol instead.

Signature

abstract get [typeNameSymbol](): string;

Type: string

[typeSchemaSymbol]

Adds a type symbol for stronger typing.

Signature

abstract get [typeSchemaSymbol](): TreeNodeSchemaClass;

Type: TreeNodeSchemaClass

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>