Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Add noUnusedLocals: true to tsconfig. (#127)
Browse files Browse the repository at this point in the history
First step in getting more of the TypeScript compiler checks on to help prevent bugs. This flag is more aesthetics than behavioral; however, it does help debugging and navigating code when looking up references.  Since so many of the models and actions were imported into classes and not used it made it appear that they were used by more classes.

I did see a few issues around using Redux `connect` and microsoft/TypeScript#5938
It's related to trying to export Props which contains types from the Models class that were not explicitly imported.
I believe this is because we are using the `returntypeof` instead of explicitly defining the interfaces.

I noticed `connect` has generic overload <StateProps, DispatchProps, OwnProps> and it internally merges them all which is what I think we should be doing; however, currently don't have well established pattern so I left code as is.
  • Loading branch information
mattmazzola authored Sep 21, 2017
1 parent 780e7e6 commit dcc9d0c
Show file tree
Hide file tree
Showing 53 changed files with 126 additions and 164 deletions.
2 changes: 1 addition & 1 deletion src/actions/createActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionObject } from '../types'
import { AT } from '../types/ActionTypes'
import { BlisAppBase, BlisAppMetaData, BlisAppList, EntityBase, EntityMetaData, EntityList, ActionBase, ActionMetaData, ActionList, ActionTypes, TrainDialog, LogDialog, Session, Teach } from 'blis-models';
import { BlisAppBase, EntityBase, ActionBase, TrainDialog, LogDialog, Session, Teach } from 'blis-models';

export const createBLISApplicationAsync = (key : string, userId : string, application: BlisAppBase): ActionObject => {

Expand Down
14 changes: 7 additions & 7 deletions src/actions/deleteActions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ActionObject } from '../types'
import { AT } from '../types/ActionTypes'
import { BlisAppBase, EntityBase, ActionBase, Session, Teach, TrainDialog, LogDialog} from 'blis-models'
import { BlisAppBase, EntityBase, ActionBase, Session, Teach, TrainDialog } from 'blis-models'

export const deleteBLISApplicationAsync = (key: string, GUID: string, blisApp: BlisAppBase): ActionObject => {

return {
type: AT.DELETE_BLIS_APPLICATION_ASYNC,
key: key,
Expand All @@ -20,7 +20,7 @@ export const deleteBLISApplicationFulfilled = (blisAppGUID: string): ActionObjec
}

export const deleteEntityAsync = (key: string, GUID: string, entity: EntityBase, currentAppId: string): ActionObject => {

return {
type: AT.DELETE_ENTITY_ASYNC,
key: key,
Expand Down Expand Up @@ -50,7 +50,7 @@ export const deleteEntityFulfilled = (key: string, deletedEntityId: string, curr
}

export const deleteActionAsync = (key: string, GUID: string, action: ActionBase, currentAppId: string): ActionObject => {

return {
type: AT.DELETE_ACTION_ASYNC,
key: key,
Expand All @@ -68,7 +68,7 @@ export const deleteActionFulfilled = (actionGUID: string): ActionObject => {
}

export const deleteChatSessionAsync = (key: string, session: Session, currentAppId: string): ActionObject => {

return {
type: AT.DELETE_CHAT_SESSION_ASYNC,
key: key,
Expand All @@ -85,12 +85,12 @@ export const deleteChatSessionFulfilled = (sessionGUID: string): ActionObject =>
}

export const deleteTeachSessionAsync = (key: string, teachSession: Teach, currentAppId: string, save: boolean): ActionObject => {

return {
type: AT.DELETE_TEACH_SESSION_ASYNC,
key: key,
teachSession: teachSession,
currentAppId: currentAppId,
currentAppId: currentAppId,
save: save
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/actions/displayActions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import { ActionObject } from '../types'
import { AT } from '../types/ActionTypes'
import { DisplayMode, TeachMode } from '../types/const'
import { BlisAppBase, BlisAppMetaData, BlisAppList, EntityBase, EntityMetaData, EntityList, ActionBase, ActionMetaData, ActionList, ActionTypes, TrainDialog, LogDialog, Session, Teach } from 'blis-models';
import { DisplayMode } from '../types/const'
import { BlisAppBase, TrainDialog, LogDialog, Session, Teach } from 'blis-models';


export const setCurrentBLISApp = (key: string, app: BlisAppBase) : ActionObject => {
Expand Down
19 changes: 12 additions & 7 deletions src/actions/fetchActions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { ActionObject } from '../types'
import { AT } from '../types/ActionTypes'
import { BlisAppBase, BlisAppMetaData, BlisAppList, BotInfo,
EntityBase, EntityMetaData, EntityList,
ActionBase, ActionMetaData, ActionList, ActionTypes,
TrainDialog, LogDialog,
Session, Teach } from 'blis-models';
import {
BlisAppBase,
BotInfo,
EntityBase,
ActionBase,
TrainDialog,
LogDialog,
Session,
Teach
} from 'blis-models';

export const fetchAllTrainDialogsAsync = (key: string, blisAppID: string): ActionObject => {
return {
Expand Down Expand Up @@ -51,12 +56,12 @@ export const fetchBotInfoFulfilled = (botInfo: BotInfo): ActionObject => {
}
}

export const fetchApplicationsAsync = (key: string, userId : string): ActionObject => {
export const fetchApplicationsAsync = (key: string, userId: string): ActionObject => {
//needs a fulfilled version to handle response from Epic
return {
type: AT.FETCH_APPLICATIONS_ASYNC,
key: key,
userId : userId
userId: userId
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/actions/teachActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionObject } from '../types'
import { AT } from '../types/ActionTypes'
import { UserInput, TrainExtractorStep, ExtractResponse, UIScoreInput, UIExtractResponse, UIScoreResponse, TrainScorerStep, TeachResponse } from 'blis-models'
import { UserInput, ExtractResponse, UIScoreInput, UIExtractResponse, UIScoreResponse, TrainScorerStep, TeachResponse } from 'blis-models'

export const runExtractorAsync = (key: string, appId: string, teachId: string, userInput: UserInput) : ActionObject => {
return {
Expand Down
3 changes: 1 addition & 2 deletions src/actions/updateActions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import { ActionObject } from '../types'
import { AT } from '../types/ActionTypes'
import { DisplayMode } from '../types/const'
import { BlisAppBase, BlisAppMetaData, BlisAppList, EntityBase, EntityMetaData, EntityList, ActionBase, ActionMetaData, ActionList, ActionTypes, TrainDialog, LogDialog, Session, Teach } from 'blis-models';
import { BlisAppBase, EntityBase, ActionBase, TrainDialog, LogDialog } from 'blis-models';

export const editBLISApplicationAsync = (key: string, application: BlisAppBase) : ActionObject => {

Expand Down
11 changes: 5 additions & 6 deletions src/containers/ActionResponseCreatorEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { editActionAsync } from '../actions/updateActions';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Modal } from 'office-ui-fabric-react/lib/Modal';
import { CommandButton, Dialog, DialogFooter, DialogType, ChoiceGroup, DefaultButton, Dropdown, TagPicker, Label, Checkbox, List } from 'office-ui-fabric-react';
import { CommandButton, Dropdown, TagPicker, Label, Checkbox, List } from 'office-ui-fabric-react';
import { TextFieldPlaceholder } from './TextFieldPlaceholder';
import { ActionBase, ActionMetaData, ActionTypes, EntityBase, EntityMetaData, EntitySuggestion } from 'blis-models'
import { ActionBase, ActionMetaData, ActionTypes, EntityBase, EntitySuggestion } from 'blis-models'
import { State } from '../types';
import EntityCreatorEditor from './EntityCreatorEditor';
import AutocompleteListItem from '../components/AutocompleteListItem';
Expand Down Expand Up @@ -350,7 +350,7 @@ class ActionResponseCreatorEditor extends React.Component<Props, any> {
}
updateSpecialCharIndexesToDisregard(newPayload: string): SpecialIndex[] {
let indexesToSet: SpecialIndex[] = [];
let requiredEntities = [...this.state.reqEntitiesVal];
// let requiredEntities = [...this.state.reqEntitiesVal];
let updatedIndex = this.findUpdatedIndex(newPayload);
if (newPayload.length > this.state.payloadVal.length) {
//we added a letter. Find which index was updated. Increment every index in the current special indexes array >= to the updated index
Expand Down Expand Up @@ -392,7 +392,7 @@ class ActionResponseCreatorEditor extends React.Component<Props, any> {
}
findWordFollowingSpecialCharacter(text: string): string {
let word: string = "";
let current: string = this.state.payloadVal;
// let current: string = this.state.payloadVal;
for (let i = this.state.dropdownIndex + 1; i < text.length; i++) {
if (text[i] !== " " && text[i] !== "") {
word += text[i]
Expand Down Expand Up @@ -545,7 +545,6 @@ class ActionResponseCreatorEditor extends React.Component<Props, any> {
}
}
findIndexOfLastCharacterFollowingSpecialCharacterPreSpace(): number {
let word: string = "";
let text: string = this.state.payloadVal;
let index: number = this.state.dropdownIndex;
for (let i = this.state.dropdownIndex + 1; i < text.length + 1; i++) {
Expand Down Expand Up @@ -602,7 +601,7 @@ class ActionResponseCreatorEditor extends React.Component<Props, any> {
let names: string[] = filteredEntities.map((e: EntityBase) => {
return e.entityName;
})
let ordered = names.sort();
names.sort();
let options: TextObject[] = names.map((name: string) => {
let ent: EntityBase = this.props.entities.find((e: EntityBase) => e.entityName == name);
return {
Expand Down
4 changes: 2 additions & 2 deletions src/containers/ActionResponsesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TrainingGroundArenaHeader from '../components/TrainingGroundArenaHeader';
import { deleteActionAsync } from '../actions/deleteActions'
import { DetailsList, CommandButton, Link, CheckboxVisibility, List, IColumn, SearchBox } from 'office-ui-fabric-react';
import ConfirmDeleteModal from '../components/ConfirmDeleteModal';
import { ActionBase, ActionMetaData, EntityBase, EntityMetaData, ModelUtils } from 'blis-models'
import { ActionBase, EntityBase, ModelUtils } from 'blis-models'
import ActionResponseCreatorEditor from './ActionResponseCreatorEditor';
import EntityTile from '../components/EntityTile';
import { State } from '../types'
Expand Down Expand Up @@ -117,7 +117,7 @@ class ActionResponsesHomepage extends React.Component<Props, any> {
})
}
onColumnClick(event: any, column: any) {
let { sortedItems, columns } = this.state;
let { columns } = this.state;
let isSortedDescending = column.isSortedDescending;

// If we've sorted this column, flip it.
Expand Down
6 changes: 1 addition & 5 deletions src/containers/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as React from 'react';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import BLISAppsHomepage from '../containers/BLISAppsHomepage';
import Header from '../components/Header';
import Docs from '../components/otherPages/Docs';
import About from '../components/otherPages/About';
import Support from '../components/otherPages/Support';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { State } from '../types'
import axios from 'axios';

export default class App extends React.Component<any, any> {
render() {
Expand Down
5 changes: 2 additions & 3 deletions src/containers/AppAdmin.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as React from 'react';
import { returntypeof } from 'react-redux-typescript';
import { fetchAllActionsAsync, fetchAllEntitiesAsync, fetchApplicationsAsync, fetchAllTrainDialogsAsync } from '../actions/fetchActions';
import { fetchApplicationsAsync } from '../actions/fetchActions';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import EntitiesList from './EntitiesList';
import TrainDialogsList from './TrainDialogsList';
import ActionResponsesList from './ActionResponsesList';
import BLISAppsHomepage from './BLISAppsHomepage';
import AppDashboard from './AppDashboard';
import AppSettings from './AppSettings';
import { Nav, INavLink, INavLinkGroup, Link } from 'office-ui-fabric-react';
import { Nav, Link } from 'office-ui-fabric-react';
import { setDisplayMode } from '../actions/displayActions';
import { State } from '../types';
import LogDialogsList from './LogDialogsList';
Expand Down
1 change: 0 additions & 1 deletion src/containers/AppDashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import { returntypeof } from 'react-redux-typescript';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import TrainingGroundArenaHeader from '../components/TrainingGroundArenaHeader'
import { State } from '../types'
Expand Down
2 changes: 1 addition & 1 deletion src/containers/AppSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import TrainingGroundArenaHeader from '../components/TrainingGroundArenaHeader'
import { State } from '../types';
import { CommandButton, ChoiceGroup, TextField, DefaultButton, Dropdown, Label, List } from 'office-ui-fabric-react';
import { CommandButton, TextField, Dropdown, Label, List } from 'office-ui-fabric-react';
import { TextFieldPlaceholder } from './TextFieldPlaceholder';
import { BlisAppBase, BlisAppMetaData } from 'blis-models'

Expand Down
2 changes: 1 addition & 1 deletion src/containers/BLISAppCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createBLISApplicationAsync } from '../actions/createActions';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Modal } from 'office-ui-fabric-react/lib/Modal';
import { CommandButton, Dialog, DialogFooter, DialogType, ChoiceGroup, TextField, DefaultButton, Dropdown } from 'office-ui-fabric-react';
import { CommandButton, Dropdown } from 'office-ui-fabric-react';
import { TextFieldPlaceholder } from './TextFieldPlaceholder';
import { setDisplayMode, emptyStateProperties } from '../actions/displayActions'
import { fetchAllActionsAsync, fetchAllEntitiesAsync, fetchAllTrainDialogsAsync } from '../actions/fetchActions';
Expand Down
9 changes: 3 additions & 6 deletions src/containers/BLISAppsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ import { deleteBLISApplicationAsync } from '../actions/deleteActions'
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import BLISAppCreator from './BLISAppCreator'
import AppAdmin from './AppAdmin';
import { DetailsList, CommandButton, Link, CheckboxVisibility, IColumn } from 'office-ui-fabric-react';
import { DetailsList, Link, CheckboxVisibility, IColumn } from 'office-ui-fabric-react';
import ConfirmDeleteModal from '../components/ConfirmDeleteModal';
import { State } from '../types';
import { BlisAppBase, BlisAppList, BlisAppMetaData } from 'blis-models'
import { DisplayMode } from '../types/const'

import { BlisAppBase } from 'blis-models'

let columns: IColumn[] = [
{
Expand Down Expand Up @@ -103,7 +100,7 @@ class BLISAppsList extends React.Component<Props, any> {
// this.props.fetchAllTeachSessions(this.props.user.key, appSelected.appId);
}
onColumnClick(event: any, column : any) {
let { sortedItems, columns } = this.state;
let { columns } = this.state;
let isSortedDescending = column.isSortedDescending;

// If we've sorted this column, flip it.
Expand Down
2 changes: 0 additions & 2 deletions src/containers/ChatSessionAdmin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';
import { returntypeof } from 'react-redux-typescript';
import { createBLISApplicationAsync } from '../actions/createActions';
import { CommandButton } from 'office-ui-fabric-react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { State } from '../types'
Expand Down
4 changes: 2 additions & 2 deletions src/containers/ChatSessionWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { returntypeof } from 'react-redux-typescript';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Nav, INavLink, INavLinkGroup, Link, CommandButton } from 'office-ui-fabric-react';
import { CommandButton } from 'office-ui-fabric-react';
import { Modal } from 'office-ui-fabric-react/lib/Modal';
import { State } from '../types';
import { DisplayMode } from '../types/const';
Expand All @@ -11,7 +11,7 @@ import ChatSessionAdmin from './ChatSessionAdmin'
import { Session } from 'blis-models'
import { deleteChatSessionAsync } from '../actions/deleteActions'
import { createChatSessionAsync } from '../actions/createActions'
import { setCurrentTrainDialog, setCurrentTeachSession, setDisplayMode } from '../actions/displayActions'
import { setDisplayMode } from '../actions/displayActions'


class SessionWindow extends React.Component<Props, any> {
Expand Down
6 changes: 3 additions & 3 deletions src/containers/EntitiesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import TrainingGroundArenaHeader from '../components/TrainingGroundArenaHeader';
import EntityCreatorEditor from './EntityCreatorEditor';
import ConfirmDeleteModal from '../components/ConfirmDeleteModal';
import { deleteEntityAsync } from '../actions/deleteActions'
import { DetailsList, CommandButton, Link, CheckboxVisibility, IColumn, SearchBox } from 'office-ui-fabric-react';
import { DetailsList, CommandButton, CheckboxVisibility, IColumn, SearchBox } from 'office-ui-fabric-react';
import { State } from '../types';
import { EntityBase, EntityIdList, EntityList, EntityMetaData, ActionBase, ActionMetaData } from 'blis-models'
import { EntityBase, ActionBase } from 'blis-models'
import { Modal } from 'office-ui-fabric-react/lib/Modal';

let columns: IColumn[] = [
Expand Down Expand Up @@ -106,7 +106,7 @@ class EntitiesList extends React.Component<Props, any> {
}
}
onColumnClick(event: any, column : any) {
let { sortedItems, columns } = this.state;
let { columns } = this.state;
let isSortedDescending = column.isSortedDescending;

// If we've sorted this column, flip it.
Expand Down
4 changes: 2 additions & 2 deletions src/containers/EntityCreatorEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { editEntityAsync } from '../actions/updateActions';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Modal } from 'office-ui-fabric-react/lib/Modal';
import { CommandButton, Dialog, DialogFooter, DialogType, ChoiceGroup, TextField, DefaultButton, Dropdown, DropdownMenuItemType, Checkbox } from 'office-ui-fabric-react';
import { CommandButton, Dropdown, DropdownMenuItemType, Checkbox } from 'office-ui-fabric-react';
import { TextFieldPlaceholder } from './TextFieldPlaceholder';
import { State, PreBuiltEntities, PreBuilts, LocalePreBuilts } from '../types';
import { State, PreBuiltEntities, LocalePreBuilts } from '../types';
import { EntityBase, EntityMetaData } from 'blis-models'

const initState = {
Expand Down
13 changes: 7 additions & 6 deletions src/containers/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as React from 'react';
import { returntypeof } from 'react-redux-typescript';
import axios from 'axios';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Modal } from 'office-ui-fabric-react/lib/Modal';
import { CommandButton, Dialog, DialogFooter, DialogType, ChoiceGroup, TextField, DefaultButton, Dropdown } from 'office-ui-fabric-react';
import { CommandButton } from 'office-ui-fabric-react';
import { clearErrorDisplay } from '../actions/displayActions'
import { State } from '../types'
type CultureObject = {
CultureCode: string;
CultureName: string;
}

// TODO: This was unused, but interested what was this used for?
// type CultureObject = {
// CultureCode: string;
// CultureName: string;
// }
class UIError extends React.Component<Props, any> {
constructor(p: any) {
super(p);
Expand Down
Loading

0 comments on commit dcc9d0c

Please sign in to comment.