Skip to content

Commit

Permalink
♻️ fix typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ppers committed Sep 22, 2023
1 parent 7a1e1f0 commit 5b95014
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/components/Checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { defineComponent } from "vue";
import UserList from "./UserList.vue";
import MD5 from "crypto-js/md5";
import { User } from "../types/mete";
export default defineComponent({
components: { UserList },
Expand All @@ -44,7 +45,7 @@ export default defineComponent({
dialogVisible: false,
form: { selectedUser: "" },
loading: false,
users: [],
users: [] as User[],
search: "",
};
},
Expand All @@ -66,7 +67,7 @@ export default defineComponent({
}
this.loading = false;
},
checkout(userId: string) {
checkout(userId: number) {
this.dialogVisible = false;
this.$emit("checkout", userId);
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/DeviceEvents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<el-button @click="clearDialog()">Abbrechen</el-button>
<el-button
type="primary"
@click="registerNfc(unregisteredNfc, selectedUser)"
@click="registerNfc(unregisteredNfc as string, selectedUser)"
:disabled="selectedUser == ''"
>NFC-Code registrieren</el-button
>
Expand Down Expand Up @@ -146,7 +146,7 @@ export default defineComponent({
this.$emit("barcode", JSON.parse((event as any).data!));
});
evtSource.addEventListener("storno", (event: Event) => {
evtSource.addEventListener("storno", (_: Event) => {
this.$emit("storno");
});
}
Expand All @@ -155,7 +155,7 @@ export default defineComponent({
return {
dialogVisible: false,
selectedUser: "",
unregisteredNfc: null,
unregisteredNfc: null as null | string,
};
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProductList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<script lang="ts">
import { defineComponent, PropType } from "vue";
import { Drink } from "../types/mete";
import { Drink } from "../types/register";
import Price from "./Price.vue";
export default defineComponent({
Expand Down
11 changes: 3 additions & 8 deletions src/components/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Checkout from "./Checkout.vue";
import Cart from "./Cart.vue";
import { Drink as MeteDrink, BarcodeRef } from "../types/mete";
import { CartDrink } from "../types/register";
import { CartDrink, Drink } from "../types/register";
import currency from "../util/currency";
interface StornoInfo {
Expand All @@ -33,11 +33,6 @@ interface StornoInfo {
stornoTimeout: number;
}
interface Drink extends MeteDrink {
barcodes: string[];
price_cents: bigint;
}
const getDrinks = async () => {
const response = await fetch("/mete/api/v1/drinks.json");
const meteDrinks: MeteDrink[] = await response.json();
Expand Down Expand Up @@ -132,7 +127,7 @@ export default defineComponent({
} catch (e) {
notify({
title: "Fehler!",
message: `${e.message}`,
message: `${(e as Error).message}`,
type: "error",
});
}
Expand Down Expand Up @@ -198,7 +193,7 @@ export default defineComponent({
} catch (e) {
notify({
title: "Fehler!",
message: `${e.message}`,
message: `${(e as Error).message}`,
type: "error",
});
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@
import { defineComponent } from "vue";
import { User } from "../types/mete";
interface UserSearchResult {
value: string;
label: string;
}
export default defineComponent({
name: "UserList",
props: { modelValue: { type: String } },
emits: ["update:modelValue"],
data() {
return {
users: [],
users: [] as UserSearchResult[],
loading: false,
wurst: null,
};
Expand Down
7 changes: 7 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
2 changes: 2 additions & 0 deletions src/types/mete.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface User {
id: number;
name: string;
email: string;
}
export interface BarcodeRef {
id: string;
Expand All @@ -11,4 +12,5 @@ export interface Drink {
name: string;
id: number;
price: string;
logo_url: string;
}
7 changes: 7 additions & 0 deletions src/types/register.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Drink as MeteDrink } from "./mete.ts";

export interface CartDrink {
name: string;
id: number;
price: bigint;
count: number;
}

export interface Drink extends MeteDrink {
barcodes: string[];
price_cents: bigint;
}
29 changes: 20 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"sourceMap": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"],
"plugins": [{ "name": "@vuedx/typescript-plugin-vue" }]

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

0 comments on commit 5b95014

Please sign in to comment.