Skip to content

Commit

Permalink
Squash almost all typescript errors (#1285)
Browse files Browse the repository at this point in the history
Switch back to typescript 2.3.4, cf. #1284
Upgrade node typings to avoid process.on("something") errors
Shun `export default const self = {methodA: {}, methodB: {}}` pattern
Enable `tsc --noEmit` phase by default in CI testing
Remove reactors/queriers and @load decorator
Tune HTML launch a little, it's not final yet
  • Loading branch information
fasterthanlime committed Jul 1, 2017
1 parent 5297f1a commit d75486f
Show file tree
Hide file tree
Showing 77 changed files with 696 additions and 929 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@types/invariant": "^2.2.28",
"@types/knex": "0.0.55",
"@types/moment-timezone": "^0.2.32",
"@types/node": "^7.0.31",
"@types/node": "^8.0.7",
"@types/pino": "^3.0.1",
"@types/proxyquire": "^1.3.27",
"@types/react": "^15.0.16",
Expand Down Expand Up @@ -159,7 +159,7 @@
"tap-out": "^2.0.0",
"tape": "^4.2.1",
"tslint": "^4.0.2",
"typescript": "^2.4.0",
"typescript": "^2.3.4",
"why-did-you-update": "^0.0.8",
"zopf": "6.1.0"
},
Expand All @@ -171,7 +171,8 @@
"upload-coverage": "codecov -f ./coverage/lcov.info",
"integration-tests": "cross-env NODE_ENV=test node ./src/integration-tests/init.js",
"i18n": "node release/ci-i18n-check.js",
"compile": "cross-env NODE_ENV=production electron-compile --appdir . ./src"
"compile": "cross-env NODE_ENV=production electron-compile --appdir . ./src",
"ts-check": "tsc --noEmit"
},
"lint-staged": {
"*.{ts,tsx}": [
Expand Down
2 changes: 2 additions & 0 deletions release/ci-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ async function main() {

$(await $.npm("install"));

$(await $.npm("run ts-check"));

if (process.platform === "linux") {
$(await $.sh('xvfb-run -a -s "-screen 0 1280x720x24" npm test -- --thorough'));
$(await $.sh('xvfb-run -a -s "-screen 0 1280x720x24" npm run integration-tests'));
Expand Down
1 change: 0 additions & 1 deletion src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export * from "./self-update-actions";
export * from "./install-locations-actions";
export * from "./modal-actions";
export * from "./preference-actions";
export * from "./query-actions";

import { createAction } from "redux-actions";

Expand Down
18 changes: 0 additions & 18 deletions src/actions/query-actions.ts

This file was deleted.

20 changes: 10 additions & 10 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import mkcooldown from "./cooldown";

import { contains } from "underscore";

import DownloadKey from "../db/models/download-key";
import { IDownloadKey } from "../db/models/download-key";
import {
ILoginKeyResult,
IUpgradeResponse,
Expand Down Expand Up @@ -302,7 +302,7 @@ export class AuthenticatedClient {
// list uploads

async listUploads(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
gameID: number,
extras: IListUploadsExtras = {},
): Promise<IListUploadsResponse> {
Expand All @@ -326,7 +326,7 @@ export class AuthenticatedClient {
// download uploads

async downloadUpload(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
): Promise<IDownloadUploadResult> {
return await this.request(
Expand All @@ -337,7 +337,7 @@ export class AuthenticatedClient {
}

downloadUploadURL(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
extras: IPasswordOrSecret = {},
): string {
Expand All @@ -353,7 +353,7 @@ export class AuthenticatedClient {
* List the N most recent builds for a wharf-enabled upload
*/
async listBuilds(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
): Promise<IListBuildsResponse> {
return await this.request(
Expand All @@ -370,7 +370,7 @@ export class AuthenticatedClient {
* Get detailed info for the given build of a given upload
*/
async build(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
buildID: number,
): Promise<IBuildResponse> {
Expand All @@ -385,7 +385,7 @@ export class AuthenticatedClient {
* Return list of patches needed to upgrade to the latest build
*/
async findUpgrade(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
currentBuildID: number,
): Promise<IUpgradeResponse> {
Expand All @@ -400,7 +400,7 @@ export class AuthenticatedClient {
* Download a given build
*/
async downloadBuild(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
buildID: number,
): Promise<IDownloadBuildResult> {
Expand All @@ -415,7 +415,7 @@ export class AuthenticatedClient {
* Returns the itchfs URL of a given build
*/
downloadBuildURL(
downloadKey: DownloadKey,
downloadKey: IDownloadKey,
uploadID: number,
buildID: number,
fileType: BuildFileType,
Expand Down Expand Up @@ -451,7 +451,7 @@ export function ensureArray(v: any): any[] {
* if downloadKey isn't null, add its id to the parameters
*/
function sprinkleDownloadKey(
downloadKey: DownloadKey | null,
downloadKey: IDownloadKey | null,
params: any,
): any {
if (!downloadKey) {
Expand Down
8 changes: 5 additions & 3 deletions src/components/collection-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { connect } from "./connect";
import { map } from "underscore";
import * as actions from "../actions";

import { ICollectionRecordSet } from "../types";
import { ICollectionSet } from "../types";
import { dispatcher } from "../constants/action-types";

import { fromJSONField } from "../db/json-field";

export class CollectionGrid extends React.PureComponent<
IProps & IDerivedProps,
void
Expand All @@ -26,7 +28,7 @@ export class CollectionGrid extends React.PureComponent<
className="collection-hub-item"
onClick={() => navigate(`collections/${id}`)}
>
{title} ({(collection.gameIds || []).length})
{title} ({fromJSONField<number[]>(collection.gameIds, []).length})
</div>
);
})}
Expand All @@ -36,7 +38,7 @@ export class CollectionGrid extends React.PureComponent<
}

interface IProps {
collections: ICollectionRecordSet;
collections: ICollectionSet;
}

interface IDerivedProps {
Expand Down
11 changes: 5 additions & 6 deletions src/components/collection-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ import TimeAgo from "./basics/time-ago";
import Ink = require("react-ink");
import interleave from "./interleave";

import { IGameRecordSet } from "../types";
import CollectionModel from "../db/models/collection";
import { IGameSet } from "../types";
import { ICollection } from "../db/models/collection";
import { multiDispatcher } from "../constants/action-types";

import styled, * as styles from "./styles";

const CollectionRowDiv = styled.div`
${styles.inkContainer()}
${styles.hubItemStyle()};
${styles.inkContainer()} ${styles.hubItemStyle()};
height: 100%;
display: flex;
Expand Down Expand Up @@ -146,8 +145,8 @@ export class CollectionRow extends React.PureComponent<
}

interface IProps {
collection: CollectionModel;
allGames: IGameRecordSet;
collection: ICollection;
allGames: IGameSet;
}

interface IDerivedProps {
Expand Down
11 changes: 5 additions & 6 deletions src/components/collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import TitleBar from "./title-bar";

import { IMeatProps } from "./meats/types";

import { IGameRecordSet, ICollectionRecord } from "../types";
import { ICollection } from "../db/models/collection";
import { IGameSet } from "../types";

import styled, * as styles from "./styles";

const CollectionDiv = styled.div`
${styles.meat()}
`;
const CollectionDiv = styled.div`${styles.meat()};`;

export class Collection extends React.PureComponent<
IProps & IDerivedProps & I18nProps,
Expand All @@ -35,7 +34,7 @@ export class Collection extends React.PureComponent<
interface IProps extends IMeatProps {}

interface IDerivedProps {
tabGames: IGameRecordSet;
collection: ICollectionRecord;
tabGames: IGameSet;
collection: ICollection;
}
export default connect<IProps>(Collection);
16 changes: 8 additions & 8 deletions src/components/collections-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as React from "react";
import { connect, I18nProps } from "./connect";
import { createSelector, createStructuredSelector } from "reselect";

import Collection from "../db/models/collection";
import { ICollection } from "../db/models/collection";
import CollectionRow from "./collection-row";

import { IAppState, ITabData, IGameRecordSet } from "../types";
import { IAppState, ITabData, IGameSet } from "../types";

import { AutoSizer, Grid } from "react-virtualized";

Expand All @@ -22,9 +22,7 @@ interface ICellInfo {

const tab = "collections";

const HubCollectionsGrid = styled.div`
flex-grow: 1;
`;
const HubCollectionsGrid = styled.div`flex-grow: 1;`;

// woo typings
const StyledGrid = (styled(Grid as any)`
Expand All @@ -47,7 +45,9 @@ export class CollectionsGrid extends React.PureComponent<

return (
<HubCollectionsGrid>
<AutoSizer>{size => this.renderWithSize(size)}</AutoSizer>
<AutoSizer>
{size => this.renderWithSize(size)}
</AutoSizer>
{hiddenCount > 0
? <div className="hidden-count">
{t("grid.hidden_count", { count: hiddenCount })}
Expand Down Expand Up @@ -120,8 +120,8 @@ export class CollectionsGrid extends React.PureComponent<
interface IProps {}

interface IDerivedProps {
games: IGameRecordSet;
collections: Collection[];
games: IGameSet;
collections: ICollection[];
hiddenCount: number;
}

Expand Down
11 changes: 5 additions & 6 deletions src/components/game-actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import MainAction from "./main-action";
import SecondaryActions from "./secondary-actions";

import { IActionsInfo } from "./types";
import GameModel from "../../db/models/game";
import { IGame } from "../../db/models/game";
import { ICaveSummary } from "../../db/models/cave";
import { IDownloadKeySummary } from "../../db/models/download-key";
import getByIds from "../../helpers/get-by-ids";
Expand Down Expand Up @@ -81,7 +81,7 @@ class GameActions extends React.PureComponent<
}

interface IProps {
game: GameModel;
game: IGame;
showSecondary?: boolean;
CustomSecondary?: typeof React.Component;
cave?: ICaveSummary;
Expand All @@ -100,7 +100,7 @@ interface IDerivedProps extends IActionsInfo {
}

interface IHappenings {
game: GameModel;
game: IGame;
caves: ICaveSummary[];
downloadKeys: IDownloadKeySummary[];
tasks: ITask[];
Expand Down Expand Up @@ -158,9 +158,8 @@ export default connect<IProps>(GameActions, {
const animate = false;
let action = actionForGame(game, cave);

const platformCompatible = action === "open"
? true
: isPlatformCompatible(game);
const platformCompatible =
action === "open" ? true : isPlatformCompatible(game);
const cancellable = false;

let downloadKey;
Expand Down
8 changes: 2 additions & 6 deletions src/components/game-actions/list-secondary-actions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as actions from "../../actions";

import { IGame } from "../../db/models/game";
import { IDownloadKey } from "../../db/models/download-key";
import { ICaveSummary } from "../../db/models/cave";

import {
IDownloadKey,
ClassificationAction,
ILocalizedString,
ITask,
} from "../../types";
import { ClassificationAction, ILocalizedString, ITask } from "../../types";

import { IAction } from "../../constants/action-types";

Expand Down
16 changes: 6 additions & 10 deletions src/components/game-actions/types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import GameModel from "../../db/models/game";
import CaveModel from "../../db/models/cave";
import { IGame } from "../../db/models/game";
import { ICave } from "../../db/models/cave";
import { IDownloadKey } from "../../db/models/download-key";

import {
IDownloadKey,
ClassificationAction,
ITask,
IDownloadItem,
} from "../../types";
import { ClassificationAction, ITask, IDownloadItem } from "../../types";

export interface IActionsInfo {
cave: CaveModel;
game: GameModel;
cave: ICave;
game: IGame;
downloadKey: IDownloadKey;

action: ClassificationAction;
Expand Down
Loading

0 comments on commit d75486f

Please sign in to comment.