diff --git a/core/comment.ts b/core/comment.ts index e6759d2d0..b408b1a69 100644 --- a/core/comment.ts +++ b/core/comment.ts @@ -87,7 +87,7 @@ export class Comment extends Icon { this.model_ = block.commentModel; // If someone creates the comment directly instead of calling // block.setCommentText we want to make sure the text is non-null; - this.model_.text = this.model_.text || ''; + this.model_.text = this.model_.text ?? ''; this.createIcon(); } @@ -153,9 +153,7 @@ export class Comment extends Icon { const textarea = this.textarea_; textarea.className = 'blocklyCommentTextarea'; textarea.setAttribute('dir', this.block_.RTL ? 'RTL' : 'LTR'); - // AnyDuringMigration because: Type 'string | null' is not assignable to - // type 'string'. - textarea.value = this.model_.text as AnyDuringMigration; + textarea.value = this.model_.text ?? ''; this.resizeTextarea_(); body.appendChild(textarea); @@ -168,7 +166,7 @@ export class Comment extends Icon { textarea, 'mouseup', this, this.startEdit_, true, true); // Don't zoom with mousewheel. this.onWheelWrapper_ = browserEvents.conditionalBind( - textarea, 'wheel', this, function(e: AnyDuringMigration) { + textarea, 'wheel', this, function(e: Event) { e.stopPropagation(); }); this.onChangeWrapper_ = browserEvents.conditionalBind( @@ -286,10 +284,7 @@ export class Comment extends Icon { */ private createNonEditableBubble_() { // TODO (#2917): It would be great if the comment could support line breaks. - // AnyDuringMigration because: Argument of type 'string | null' is not - // assignable to parameter of type 'string'. - this.paragraphElement_ = - Bubble.textToDom(this.block_.getCommentText() as AnyDuringMigration); + this.paragraphElement_ = Bubble.textToDom(this.model_.text ?? ''); this.bubble_ = Bubble.createNonEditableBubble( this.paragraphElement_, (this.block_), this.iconXY_ as Coordinate); this.applyColour(); @@ -368,9 +363,7 @@ export class Comment extends Icon { */ updateText() { if (this.textarea_) { - // AnyDuringMigration because: Type 'string | null' is not assignable to - // type 'string'. - this.textarea_.value = this.model_.text as AnyDuringMigration; + this.textarea_.value = this.model_.text ?? ''; } else if (this.paragraphElement_) { // Non-Editable mode. // TODO (#2917): If 2917 gets added this will probably need to be updated.