common: fix ts errors

This commit is contained in:
ammarahm-ed
2023-08-26 20:10:34 +05:00
committed by Abdullah Atta
parent 843be2a62c
commit 9ef40c01ce
4 changed files with 16 additions and 12 deletions

View File

@@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
import Database from "@notesnook/core/dist/api/index";
export const database = new Database();

View File

@@ -17,24 +17,29 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { formatDate } from "@notesnook/core/dist/utils/date";
import {
FormatDateOptions,
TimeFormat,
formatDate
} from "@notesnook/core/dist/utils/date";
import { database } from "../database";
import { formatReminderTime } from "@notesnook/core/dist/collections/reminders";
import { Reminder } from "@notesnook/core/dist/types";
export function getFormattedDate(
date: string | number | Date,
type: "time" | "date-time" | "date" = "date-time"
type: FormatDateOptions["type"]
) {
return formatDate(date, {
dateFormat: database.settings?.getDateFormat() as string,
timeFormat: database.settings?.getTimeFormat() as string,
type: type
});
} as FormatDateOptions);
}
export function getFormattedReminderTime(reminder: any, short = false) {
export function getFormattedReminderTime(reminder: Reminder, short = false) {
return formatReminderTime(reminder, short, {
dateFormat: database.settings?.getDateFormat() as string,
timeFormat: database.settings?.getTimeFormat() as string
timeFormat: database.settings?.getTimeFormat() as TimeFormat
});
}

View File

@@ -16,9 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Item } from "@notesnook/core/dist/types";
import { database } from "../database";
export function getTotalNotes(item?: any) {
export function getTotalNotes(item?: Item) {
if (!item || (item.type !== "notebook" && item.type !== "topic")) return 0;
if (item.type === "topic") {
return (