More longstanding type error fixes

This commit is contained in:
Rick Carlino 2017-09-28 07:41:56 -05:00
parent 528fe54b90
commit 17cbd3c7f2
5 changed files with 11 additions and 20 deletions

View file

@ -10,7 +10,7 @@ import { edit, save } from "../api/crud";
import { updateNO } from "../resources/actions";
import { deleteUser } from "./actions";
import { success } from "farmbot-toastr/dist";
import { LabsFeatures } from "./labs_features";
import { LabsFeatures } from "./labs/labs_features";
const KEYS: (keyof User)[] = ["id", "name", "email", "created_at", "updated_at"];

View file

@ -1,5 +1,5 @@
import * as React from "react";
import { WidgetHeader, Widget, WidgetBody } from "../ui/index";
import { WidgetHeader, Widget, WidgetBody } from "../../ui/index";
import { LabsFeaturesList } from "./labs_features_list_ui";
import { maybeToggleFeature } from "./labs_features_list_data";

View file

@ -1,6 +1,6 @@
import { BooleanSetting } from "../session_keys";
import { Session } from "../session";
import { Content } from "../constants";
import { Content } from "../../constants";
import { Session } from "../../session";
import { BooleanSetting } from "../../session_keys";
export interface LabsFeature {
name: string;

View file

@ -1,6 +1,6 @@
import * as React from "react";
import { fetchLabFeatures, LabsFeature } from "./labs_features_list_data";
import { KeyValShowRow } from "../controls/key_val_show_row";
import { KeyValShowRow } from "../../controls/key_val_show_row";
interface LabsFeaturesListProps {
onToggle(feature: LabsFeature): void;

View file

@ -136,7 +136,7 @@ export function isMobile() {
* Array, Symbol, etc)
*/
export function safeStringFetch(obj: {}, key: string): string {
const boxed = box(obj[key]);
const boxed = box((obj as Dictionary<{}>)[key]);
switch (boxed.kind) {
case "undefined":
case "null":
@ -173,7 +173,7 @@ export function stopIE() {
}
}
const REQUIRED_ARRAY_METHODS = ["includes", "map", "filter"];
for (i = 0; i < REQUIRED_ARRAY_METHODS.length; i++) {
for (let i = 0; i < REQUIRED_ARRAY_METHODS.length; i++) {
if (!Array.prototype.hasOwnProperty(REQUIRED_ARRAY_METHODS[i])) {
flunk();
}
@ -187,15 +187,6 @@ export function pick<T, K extends keyof T>(target: T, key: K): T[K] {
return target[key];
}
/** _Safely_ check a value at runtime to know if it can be used for square
* bracket access.
*/
export function hasKey<T>(base: (keyof T)[]) {
return (target: T | {}): target is keyof T => {
return base.includes(target);
};
}
/** Useful for calculating uploads and progress bars for Promise.all */
export class Progress {
constructor(public total: number,
@ -260,10 +251,10 @@ export function smoothScrollToBottom() {
}
/** Fancy debug */
export function fancyDebug(t: {}) {
export function fancyDebug(d: {}) {
console.log(Object
.keys(t)
.map(key => [key, t[key]])
.keys(d)
.map(key => [key, (d as Dictionary<string>)[key]])
.map((x) => {
const key = _.padStart(x[0], 20, " ");
const val = (JSON.stringify(x[1]) || "Nothing").slice(0, 52);