From 41f445c7a049f8f6b38113eb506000a16dfebec9 Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Fri, 29 Dec 2023 20:02:17 -0600 Subject: [PATCH] update a few more components to typescript --- components/{MDContent.js => MDContent.tsx} | 15 ++++++++++++--- pages/{_app.js => _app.tsx} | 0 pages/{_document.js => _document.tsx} | 0 pages/notes/{[id].js => [id].tsx} | 9 ++++----- pages/notes/{index.js => index.tsx} | 0 tsconfig.json | 1 + 6 files changed, 17 insertions(+), 8 deletions(-) rename components/{MDContent.js => MDContent.tsx} (87%) rename pages/{_app.js => _app.tsx} (100%) rename pages/{_document.js => _document.tsx} (100%) rename pages/notes/{[id].js => [id].tsx} (73%) rename pages/notes/{index.js => index.tsx} (100%) diff --git a/components/MDContent.js b/components/MDContent.tsx similarity index 87% rename from components/MDContent.js rename to components/MDContent.tsx index 4ca224e..bb432e3 100644 --- a/components/MDContent.js +++ b/components/MDContent.tsx @@ -1,14 +1,16 @@ import React from 'react'; import { useRouter } from 'next/router' -function BackLinks({ linkList }) { +interface BackLinksProps { + linkList: unknown[] +} +function BackLinks({ linkList }) { return (

Link to this note

{(linkList != null && linkList.length > 0) ? <> -
{linkList.map(aLink =>
@@ -26,7 +28,14 @@ function BackLinks({ linkList }) {
); } -function MDContent({ content, backLinks, handleOpenNewContent }) { + +interface MDContentProps { + content: unknown + backLinks: unknown[] + handleOpenNewContent: (arg?: unknown) => void +} + +function MDContent({ content, backLinks, handleOpenNewContent }: MDContentProps) { function _handleInternalLinkClick() { //Processing fetching diff --git a/pages/_app.js b/pages/_app.tsx similarity index 100% rename from pages/_app.js rename to pages/_app.tsx diff --git a/pages/_document.js b/pages/_document.tsx similarity index 100% rename from pages/_document.js rename to pages/_document.tsx diff --git a/pages/notes/[id].js b/pages/notes/[id].tsx similarity index 73% rename from pages/notes/[id].js rename to pages/notes/[id].tsx index eb6b61b..fe25eda 100644 --- a/pages/notes/[id].js +++ b/pages/notes/[id].tsx @@ -2,7 +2,6 @@ import Head from "next/head"; import Layout from "../../components/Layout"; import Util from "../../lib/utils" import FolderTree from "../../components/FolderTree"; -import { getFlattenArray } from "../../lib/utils"; import MDContent from "../../components/MDContent"; @@ -17,7 +16,7 @@ export default function Home({ note, backLinks, fileNames, tree, flattenNodes }) - +
@@ -41,15 +40,15 @@ export function getStaticProps({ params }) { const tree = Util.convertObject(Util.getDirectoryData()); const flattenNodes = Util.getFlattenArray(tree) - const listOfEdges = edges.filter(anEdge => anEdge.target === params.id) - const internalLinks = listOfEdges.map(anEdge => nodes.find(aNode => aNode.slug === anEdge.source)).filter(element => element !== undefined) + const listOfEdges: unknown[] = edges.filter(anEdge => anEdge.target === params.id) + const internalLinks: unknown[] = listOfEdges.map(anEdge => nodes.find(aNode => aNode.slug === anEdge.source)).filter(element => element !== undefined) const backLinks = [...new Set(internalLinks)] return { props: { note, tree: tree, flattenNodes: flattenNodes, - backLinks: backLinks.filter(link => link.slug !== params.id), + backLinks: backLinks.filter((link: Array) => link.slug !== params.id), }, }; } diff --git a/pages/notes/index.js b/pages/notes/index.tsx similarity index 100% rename from pages/notes/index.js rename to pages/notes/index.tsx diff --git a/tsconfig.json b/tsconfig.json index 65348e8..a2570c1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "target": "ESNext", "lib": [ "dom", "dom.iterable",