[UNSTABLE] Type errors gone. NEXT: test suite
This commit is contained in:
parent
f69904fb29
commit
c4bf151a30
|
@ -72,27 +72,12 @@ export class API {
|
|||
|
||||
/** "https:" or "http:". NO "//"! */
|
||||
private readonly protocol: ProtocolString;
|
||||
/** "localhost", "yahoo.com" */
|
||||
private readonly hostname: string;
|
||||
/** "80", "443" or "" */
|
||||
private readonly port: string;
|
||||
/** "/pathname/x/whatever" or "/foo/" */
|
||||
private readonly pathname: string;
|
||||
/** "?foo=bar" */
|
||||
private readonly search: string;
|
||||
/** "#hashfragment" */
|
||||
private readonly hash: string;
|
||||
/** "example.com:3000" */
|
||||
private readonly host: string;
|
||||
|
||||
constructor(input: string) {
|
||||
const url = API.parseURL(input);
|
||||
this.protocol = url.protocol as ProtocolString;
|
||||
this.hostname = url.hostname;
|
||||
this.port = url.port;
|
||||
this.pathname = url.pathname;
|
||||
this.search = url.search;
|
||||
this.hash = url.hash;
|
||||
this.host = url.host;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import * as _ from "lodash";
|
|||
|
||||
export class AxisInputBoxGroup extends
|
||||
React.Component<AxisInputBoxGroupProps, Partial<AxisInputBoxGroupState>> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: AxisInputBoxGroupProps) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import { ToolTips } from "../../constants";
|
|||
import * as _ from "lodash";
|
||||
|
||||
export class Peripherals extends React.Component<PeripheralsProps, PeripheralState> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: PeripheralsProps) {
|
||||
super(props);
|
||||
this.state = { isEditing: false };
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ enum ColumnWidth {
|
|||
|
||||
export class PinBindings
|
||||
extends React.Component<PinBindingsProps, PinBindingsState> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: PinBindingsProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isEditing: false,
|
||||
pinNumberInput: undefined,
|
||||
|
@ -97,8 +97,8 @@ export class PinBindings
|
|||
{`Pi GPIO ${pin_number}`}
|
||||
</Col>
|
||||
<Col xs={ColumnWidth.sequence}>
|
||||
{findSequenceById(
|
||||
resources, parseInt(sequence_id)).body.name}
|
||||
{sequence_id ? findSequenceById(
|
||||
resources, parseInt(sequence_id)).body.name : ""}
|
||||
</Col>
|
||||
<Col xs={ColumnWidth.button}>
|
||||
<button
|
||||
|
|
|
@ -24,8 +24,8 @@ interface State {
|
|||
export class AddFarmEvent
|
||||
extends React.Component<AddEditFarmEventProps, Partial<State>> {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: AddEditFarmEventProps) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ const DRAG_ERROR = `ERROR - Couldn't get zoom level of garden map, check the
|
|||
|
||||
export class GardenMap extends
|
||||
React.Component<GardenMapProps, Partial<GardenMapState>> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: GardenMapProps) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ export function FarmwareConfigMenu(props: FarmwareConfigMenuProps) {
|
|||
}
|
||||
|
||||
export class FarmwarePanel extends React.Component<FWProps, Partial<FWState>> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: FWProps) {
|
||||
super(props);
|
||||
this.state = { showFirstParty: false };
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ describe("<Body/>", () => {
|
|||
it("triggers onChange() event", () => {
|
||||
jest.clearAllMocks();
|
||||
const props = fakeProps();
|
||||
const iw = new ImageWorkspace();
|
||||
const iw = new ImageWorkspace(props);
|
||||
iw.props = props;
|
||||
iw.onHslChange("H")([4, 5]);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(2);
|
||||
|
|
|
@ -2,7 +2,7 @@ import { DropDownItem } from "../../ui/index";
|
|||
import { SPECIAL_VALUES } from "./remote_env/constants";
|
||||
|
||||
/** Mapping of SPECIAL_VALUE numeric codes into corresponding drop down items. */
|
||||
export const SPECIAL_VALUE_DDI = {
|
||||
export const SPECIAL_VALUE_DDI: { [index: number]: DropDownItem } = {
|
||||
[SPECIAL_VALUES.X]: {
|
||||
label: "X",
|
||||
value: SPECIAL_VALUES.X
|
||||
|
|
|
@ -47,8 +47,8 @@ export function getHueBoxes(
|
|||
}
|
||||
|
||||
export class FarmbotColorPicker extends React.Component<FarmbotPickerProps, {}> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: FarmbotPickerProps) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import { translateImageWorkspaceAndSave } from "./actions";
|
|||
@connect(mapStateToProps)
|
||||
export class WeedDetector
|
||||
extends React.Component<FarmwareProps, Partial<DetectorState>> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: FarmwareProps) {
|
||||
super(props);
|
||||
this.state = { remoteFarmwareSettings: {} };
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import { ResendVerification } from "./resend_verification";
|
|||
import { CreateAccount } from "./create_account";
|
||||
|
||||
export class FrontPage extends React.Component<{}, Partial<FrontPageState>> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: {}) {
|
||||
super(props);
|
||||
this.state = {
|
||||
registrationSent: false,
|
||||
regEmail: "",
|
||||
|
|
|
@ -17,8 +17,8 @@ export interface State {
|
|||
export interface Props { }
|
||||
|
||||
export class PasswordReset extends React.Component<Props, State> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
password: "",
|
||||
passwordConfirmation: "",
|
||||
|
|
|
@ -21,8 +21,8 @@ interface State {
|
|||
}
|
||||
|
||||
export class TosUpdate extends React.Component<Props, Partial<State>> {
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.submit = this.submit.bind(this);
|
||||
this.toggleServerOpts = this.toggleServerOpts.bind(this);
|
||||
this.state = {
|
||||
|
|
|
@ -21,23 +21,23 @@ interface SaveBtnProps {
|
|||
const spinner = <span className="btn-spinner" />;
|
||||
|
||||
export function SaveBtn(props: SaveBtnProps) {
|
||||
const STATUS_TRANSLATION = {
|
||||
const STATUS_TRANSLATION: Partial<Record<SpecialStatus, string>> = {
|
||||
[SpecialStatus.DIRTY]: "is-dirty",
|
||||
[SpecialStatus.SAVING]: "is-saving"
|
||||
};
|
||||
|
||||
const CAPTIONS = {
|
||||
const CAPTIONS: Partial<Record<SpecialStatus, string>> = {
|
||||
[SpecialStatus.DIRTY]: t((props.dirtyText || "Save ") + " *"),
|
||||
[SpecialStatus.SAVING]: t(props.savingText || "Saving")
|
||||
};
|
||||
|
||||
const { onClick, hidden } = props;
|
||||
const { savedText, onClick, hidden } = props;
|
||||
const statusClass = STATUS_TRANSLATION[props.status || ""] || "is-saved";
|
||||
const klass = `${props.color || "green"} ${statusClass} save-btn fb-button`;
|
||||
const spinnerEl = (props.status === SpecialStatus.SAVING) ?
|
||||
spinner : "";
|
||||
|
||||
return <button onClick={onClick} hidden={!!hidden} className={klass} >
|
||||
{CAPTIONS["" + props.status] || (t(savedText || "Saved ") + " ✔")} {spinnerEl}
|
||||
{CAPTIONS[props.status] || (t(savedText || "Saved ") + " ✔")} {spinnerEl}
|
||||
</button>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue