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

Add TypeScript support #5027

Merged
merged 13 commits into from
Jul 16, 2020
Merged
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
3 changes: 2 additions & 1 deletion client/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
],
"useBuiltIns": "usage"
}],
"@babel/preset-react"
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
Expand Down
33 changes: 28 additions & 5 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
module.exports = {
root: true,
extends: ["react-app", "plugin:compat/recommended", "prettier"],
plugins: ["jest", "compat", "no-only-tests"],
parser: "@typescript-eslint/parser",
extends: [
"react-app",
"plugin:compat/recommended",
"prettier",
// Remove any typescript-eslint rules that would conflict with prettier
"prettier/@typescript-eslint",
],
plugins: ["jest", "compat", "no-only-tests", "@typescript-eslint"],
settings: {
"import/resolver": "webpack"
"import/resolver": "webpack",
},
env: {
browser: true,
node: true
node: true,
},
rules: {
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
"jsx-a11y/anchor-is-valid": "off",
}
},
overrides: [
{
// Only run typescript-eslint on TS files
files: ["*.ts", "*.tsx", ".*.ts", ".*.tsx"],
extends: ["plugin:@typescript-eslint/recommended"],
rules: {
// Do not require functions (especially react components) to have explicit returns
"@typescript-eslint/explicit-function-return-type": "off",
// Do not require to type every import from a JS file to speed up development
"@typescript-eslint/no-explicit-any": "off",
// Do not complain about useless contructors in declaration files
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",
},
},
],
};
18 changes: 18 additions & 0 deletions client/app/components/empty-state/EmptyState.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";

export interface EmptyStateProps {
header?: string;
icon?: string;
description: string;
illustration: string;
helpLink: string;

onboardingMode?: boolean;
showAlertStep?: boolean;
showDashboardStep?: boolean;
showInviteStep?: boolean;
}

declare const EmptyState: React.FunctionComponent<EmptyStateProps>;

export default EmptyState;
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import React from "react";
import PropTypes from "prop-types";
import * as React from "react";
import * as PropTypes from "prop-types";
import BigMessage from "@/components/BigMessage";
import NoTaggedObjectsFound from "@/components/NoTaggedObjectsFound";
import EmptyState from "@/components/empty-state/EmptyState";

export default function DashboardListEmptyState({ page, searchTerm, selectedTags }) {
export interface DashboardListEmptyStateProps {
simonschneider-db marked this conversation as resolved.
Show resolved Hide resolved
page: string;
searchTerm: string;
selectedTags: string[];
}

export default function DashboardListEmptyState({ page, searchTerm, selectedTags }: DashboardListEmptyStateProps) {
if (searchTerm !== "") {
return <BigMessage message="Sorry, we couldn't find anything." icon="fa-search" />;
}
Expand All @@ -30,5 +36,5 @@ export default function DashboardListEmptyState({ page, searchTerm, selectedTags
DashboardListEmptyState.propTypes = {
page: PropTypes.string.isRequired,
searchTerm: PropTypes.string.isRequired,
selectedTags: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
selectedTags: PropTypes.array.isRequired,
};
9 changes: 0 additions & 9 deletions client/jsconfig.json

This file was deleted.

35 changes: 35 additions & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"compilerOptions": {
// Target latest version of ECMAScript.
"target": "esnext",
// Search under node_modules for non-relative imports.
"moduleResolution": "node",
// Process & infer types from .js files.
"allowJs": true,
// Don't emit; allow Babel to transform files.
"noEmit": true,
// Enable strictest settings like strictNullChecks & noImplicitAny.
"strict": true,
// Import non-ES modules as default imports.
"esModuleInterop": true,
"jsx": "react",
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"forceConsistentCasingInFileNames": true,
"baseUrl": "./",
"paths": {
"@/*": ["./app/*"]
}
},
"include": [
"app/**/*"
],
"exclude": [
"dist"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add explicit include to avoid compiling non-source files? Something like:

Suggested change
}
"include": [
"app"
]
}

Loading