#667 - add sanity messages when data is read before type is added to a document.

This commit is contained in:
Kevin Jahns
2024-10-04 21:07:19 +02:00
parent 8cd1a482bb
commit 3bf44b9850
5 changed files with 35 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ import {
typeMapGetAll,
updateMarkerChanges,
ContentType,
warnPrematureAccess,
ArraySearchMarker, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, ID, Doc, Item, Snapshot, Transaction // eslint-disable-line
} from '../internals.js'
@@ -875,6 +876,7 @@ export class YText extends AbstractType {
* @type {number}
*/
get length () {
this.doc ?? warnPrematureAccess()
return this._length
}
@@ -931,6 +933,7 @@ export class YText extends AbstractType {
* @public
*/
toString () {
this.doc ?? warnPrematureAccess()
let str = ''
/**
* @type {Item|null}
@@ -1004,6 +1007,7 @@ export class YText extends AbstractType {
* @public
*/
toDelta (snapshot, prevSnapshot, computeYChange) {
this.doc ?? warnPrematureAccess()
/**
* @type{Array<any>}
*/