Skip to content

Commit

Permalink
chore: fix almost all typescript issues
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Nov 3, 2023
1 parent c47d520 commit a79101c
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 29 deletions.
11 changes: 10 additions & 1 deletion src/bootstrap/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { App } from "vue";
// PROJECT: FILTERS
import dateFilters from "@/filters/date";

/**************************************************************************
* INTERFACES
* ************************************************************************* */

interface Filters {
date: typeof dateFilters;
}

/**************************************************************************
* FILTERS
* ************************************************************************* */
Expand All @@ -22,12 +30,13 @@ class BootstrapFilters {
init(app: App): void {
app.config.globalProperties.$filters = {
date: dateFilters
};
} as Filters;
}
}

/**************************************************************************
* EXPORTS
* ************************************************************************* */

export type { Filters };
export default new BootstrapFilters();
6 changes: 1 addition & 5 deletions src/broker/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ class BrokerClient {

// Connect client
try {
await client.connect(
jid,
password,
Store.$presence.getLocalAvailability()
);
await client.connect(jid, password);
} catch (error) {
logger.error("Something went wrong", error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/BaseBadgeDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {

props: {
details: {
type: Array,
type: Array<Detail>,
required: true,

validator(x: Array<Detail>): boolean {
Expand Down
18 changes: 9 additions & 9 deletions src/components/base/BaseDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default {

props: {
columns: {
type: Array,
type: Array<Column>,
required: true,

validator(x: Array<Column>): boolean {
Expand All @@ -156,7 +156,7 @@ export default {
},

rows: {
type: Array,
type: Array<Row>,
required: true,

validator(x: Array<Row>): boolean {
Expand All @@ -174,7 +174,7 @@ export default {
},

controls: {
type: Array,
type: Array<Control>,

default(): Array<Control> {
return [];
Expand All @@ -194,8 +194,8 @@ export default {
// --> STATE <--

orderBy: {
columnId: null,
direction: 0
columnId: null as string | null,
direction: 0 as -1 | 0 | 1
}
};
},
Expand Down Expand Up @@ -233,11 +233,11 @@ export default {
this.orderBy.columnId !== null &&
this.orderBy.direction !== 0
) {
const columnId = this.orderBy.columnId,
direction = this.orderBy.direction === -1 ? -1 : 1;

return [...this.rows].sort(
firstBy(
row => row.columns[this.orderBy.columnId],
this.orderBy.direction
)
firstBy(row => row.columns[columnId], direction)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/base/BaseNavigate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default {

props: {
sections: {
type: Array,
type: Array<Section>,
required: true,

validator(x: Array<Section>): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/BasePopoverList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default {

props: {
items: {
type: Array,
type: Array<Item>,
required: true,

validator(x: Array<Item>): boolean {
Expand Down
6 changes: 4 additions & 2 deletions src/components/form/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,10 @@ export default {
},

onFieldKeyUp(event: KeyboardEvent): void {
// Propagate key event
this.$emit("keystroke", event.target.value);
if (event.target) {
// Propagate key event
this.$emit("keystroke", (event.target as HTMLInputElement).value);
}
},

onFieldInput(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/components/inbox/InboxDetailsGenericActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
},

actions: {
type: Array,
type: Array<Action>,
required: true,

validator(x: Array<Action>): boolean {
Expand Down
6 changes: 3 additions & 3 deletions src/components/inbox/InboxDetailsUserInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default {

computed: {
entries(): Array<Entry> {
const entries = [];
const entries: Array<Entry> = [];

if (this.profile.information) {
if (this.profile.information.contact) {
Expand All @@ -127,7 +127,7 @@ export default {
}
}

if (this.profile.information.lastActive) {
if (this.profile.information.lastActive?.timestamp) {
const activePrefix =
this.availability !== Availability.Unavailable
? "Active"
Expand Down Expand Up @@ -190,7 +190,7 @@ export default {
id: "location",
title: locationParts.join(", "),
icon: "location.fill",
flag: userCountryCode
flag: userCountryCode || undefined
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/inbox/InboxDetailsUserSecurity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default {

detailsPopover: {
id: "",
component: null
component: null as object | null
}
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ export default {
userName(): string {
if (this.profile.name) {
return `${this.profile.name.first} ${this.profile.name.last}`;
} else {
return this.jid.node;
}

return this.jid.node || this.jid.toString();
},

identityUrl(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export default {

props: {
fieldsets: {
type: Array,
type: Array<Fieldset>,
required: true,

validator(x: Array<Fieldset>): boolean {
Expand Down
15 changes: 15 additions & 0 deletions src/shims-vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
* Copyright 2023, Prose Foundation
*/

/**************************************************************************
* IMPORTS
* ************************************************************************* */

// PROJECT: FILTERS
import { Filters } from "@/bootstrap/filters";

/**************************************************************************
* DECLARES
* ************************************************************************* */
Expand All @@ -13,3 +20,11 @@ declare module "*.vue" {

export default Vue;
}

declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
$filters: Filters;
}
}

export {};
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"esModuleInterop": true,
"skipLibCheck": true,
"noEmit": true,
"lib": ["ESNext", "DOM"],
"allowJs": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"types": ["node", "vite-plugin-svg-icons/client"],
"baseUrl": "src/",

Expand Down

0 comments on commit a79101c

Please sign in to comment.