From 2dfb2b7ecb9e10ffdc1aa45af460d589620a4eff Mon Sep 17 00:00:00 2001 From: SuperSuperDev Date: Sat, 7 Aug 2021 20:42:35 +0700 Subject: [PATCH] feat!: use typescript --- .eslintrc | 4 +++ components/{Button.jsx => Button.tsx} | 12 +++++++- components/{CustomLink.jsx => CustomLink.tsx} | 6 ++-- components/{Nav.jsx => Nav.tsx} | 10 +++++-- components/{Seo.jsx => Seo.tsx} | 28 +++++++++++++----- .../{UnstyledLink.jsx => UnstyledLink.tsx} | 12 ++++++-- jsconfig.json | 11 ------- lib/helper.js | 3 -- lib/helper.ts | 3 ++ next-env.d.ts | 3 ++ package.json | 6 ++-- pages/{_app.js => _app.tsx} | 0 pages/{_document.js => _document.tsx} | 0 pages/{index.jsx => index.tsx} | 10 +++---- tsconfig.json | 24 +++++++++++++++ yarn.lock | 29 +++++++++++++++++++ 16 files changed, 122 insertions(+), 39 deletions(-) rename components/{Button.jsx => Button.tsx} (51%) rename components/{CustomLink.jsx => CustomLink.tsx} (76%) rename components/{Nav.jsx => Nav.tsx} (73%) rename components/{Seo.jsx => Seo.tsx} (71%) rename components/{UnstyledLink.jsx => UnstyledLink.tsx} (70%) delete mode 100644 jsconfig.json delete mode 100644 lib/helper.js create mode 100644 lib/helper.ts create mode 100644 next-env.d.ts rename pages/{_app.js => _app.tsx} (100%) rename pages/{_document.js => _document.tsx} (100%) rename pages/{index.jsx => index.tsx} (84%) create mode 100644 tsconfig.json diff --git a/.eslintrc b/.eslintrc index 359893e..f72ff5c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,5 +8,9 @@ "rules": { "no-unused-vars": "warn", "no-console": "warn" + }, + "globals": { + "React": true, + "JSX": true } } diff --git a/components/Button.jsx b/components/Button.tsx similarity index 51% rename from components/Button.jsx rename to components/Button.tsx index 2058bb2..0fce62c 100644 --- a/components/Button.jsx +++ b/components/Button.tsx @@ -1,6 +1,16 @@ import clsx from 'clsx'; -export default function Button({ children, className = '', ...rest }) { +type ButtonProps = { + href: string; + children: React.ReactChild | string; + className?: string; +} & React.ComponentPropsWithoutRef<'button'>; + +export default function Button({ + children, + className = '', + ...rest +}: ButtonProps) { return (