Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS integration WIP #225

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.module.scss" {
const content: { [className: string]: string };
export default content;
}
226 changes: 218 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"stylelint-prettier": "^3.0.0",
"stylelint-webpack-plugin": "^4.1.0",
"terser-webpack-plugin": "^5.3.7",
"typescript": "^5.0.2",
"ts-loader": "^9.4.4",
"typescript": "^5.1.6",
"webpack": "^5.76.2",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^5.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./SkipLink.module.scss";

const SkipLink = (props) => {
const handleClick = (e) => {
interface SkipLinkProps {
to: string;
children: React.ReactNode;
}

const SkipLink = (props: SkipLinkProps) => {
const handleClick = (e: React.MouseEvent) => {
const href = e.currentTarget.getAttribute("href");

if (href && href.indexOf("#") === 0) {
Expand All @@ -27,13 +31,4 @@ const SkipLink = (props) => {
);
};

//TODO Convert proptypes to typescript
SkipLink.propTypes = {
to: PropTypes.string.isRequired,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]).isRequired,
};

export default SkipLink;
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"allowJs": true,
"esModuleInterop": true,
"moduleResolution": "node"
}
}
8 changes: 8 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ module.exports = function (env, argv) {

module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: "ts-loader",
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
},
{
test: /\.jsx?$/,
enforce: "pre",
Expand Down