From 9cbae654f5bf9d70279a7a9fe3849f44485ca9fd Mon Sep 17 00:00:00 2001 From: dependentmadani Date: Thu, 4 Jul 2024 12:13:44 +0100 Subject: [PATCH] update(data type): reformulate the data type and function of nomalizeData --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 48b14e4..2343d24 100644 --- a/src/index.ts +++ b/src/index.ts @@ -116,7 +116,7 @@ export default class Header { * @type {HeaderData} * @private */ - this._data = this.normalizeData(data as HeaderData); + this._data = this.normalizeData(data); /** * Main Block wrapper @@ -155,15 +155,15 @@ export default class Header { * @returns {HeaderData} * @private */ - normalizeData(data: HeaderData): HeaderData { + normalizeData(data: HeaderData | {}): HeaderData { const newData: HeaderData = { text: '', level: this.defaultLevel.number }; if (!this.isHeaderData(data)) { data = { text: '', level: this.defaultLevel.number}; } - newData.text = data.text || ''; - newData.level = parseInt(data.level.toString()) || this.defaultLevel.number; + newData.text = (data as HeaderData).text || ''; + newData.level = parseInt((data as HeaderData).level.toString()) || this.defaultLevel.number; return newData; }