Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: fix typescript issues
Andrew Bastin4508e309c24a
diff --git a/components/http/BodyParameters.vue b/components/http/BodyParameters.vueindex 261f933e5..037c37528 100644--- a/components/http/BodyParameters.vue+++ b/components/http/BodyParameters.vue@@ -135,15 +135,10 @@</AppSection></template>-<script lang="ts">-import { defineComponent, toRef } from "@nuxtjs/composition-api"-import { useRESTRequestBody } from "~/newstore/RESTSession"--export default defineComponent({- setup() {- return {- bodyParams: toRef(useRESTRequestBody(), "body"),- }+<script>+export default {+ props: {+ bodyParams: { type: Array, default: () => [] },},computed: {contentType() {@@ -168,15 +163,15 @@ export default defineComponent({}},methods: {- clearContent(bodyParams: string, $event: any) {+ clearContent(bodyParams, $event) {this.$emit("clear-content", bodyParams, $event)},setRouteQueryState() {this.$emit("set-route-query-state")},- removeRequestBodyParam(index: number) {+ removeRequestBodyParam(index) {const paramArr = this.$store.state.request.bodyParams.filter(- (item: { active: boolean }, itemIndex: any) =>+ (item, itemIndex) =>itemIndex !== index &&(Object.prototype.hasOwnProperty.call(item, "active")? item.active === true@@ -188,45 +183,40 @@ export default defineComponent({addRequestBodyParam() {this.$emit("add-request-body-param")},- setRequestAttachment(event: { target: { files: any } }, index: number) {+ setRequestAttachment(event, index) {const { files } = event.targetthis.$store.commit("setFilesBodyParams", {index,value: Array.from(files),})},- requestBodyParamIsFile(index: number) {+ requestBodyParamIsFile(index) {const bodyParamValue = this.bodyParams?.[index]?.valueconst isFile = bodyParamValue?.[0] instanceof Filereturn isFile},- chipDelete(paramIndex: number, fileIndex: number) {+ chipDelete(paramIndex, fileIndex) {this.$store.commit("removeFile", {index: paramIndex,fileIndex,})},- updateBodyParams(- event: { target: { value: any } },- index: number,- type: string- ) {+ updateBodyParams(event, index, type) {this.$store.commit(type, {index,value: event.target.value,})- const paramArr = this.$store.state.request.bodyParams.filter(- (item: { active: boolean }) =>- Object.prototype.hasOwnProperty.call(item, "active")- ? item.active === true- : true+ const paramArr = this.$store.state.request.bodyParams.filter((item) =>+ Object.prototype.hasOwnProperty.call(item, "active")+ ? item.active === true+ : true)this.setRawParams(paramArr)},- toggleActive(index: number, param: { active: any }) {+ toggleActive(index, param) {const paramArr = this.$store.state.request.bodyParams.filter(- (item: { active: boolean }, itemIndex: any) => {+ (item, itemIndex) => {if (index === itemIndex) {return !param.active} else {@@ -246,9 +236,9 @@ export default defineComponent({: false,})},- setRawParams(filteredParamArr: any[]) {+ setRawParams(filteredParamArr) {let rawParams = {}- filteredParamArr.forEach((_param: { key: any; value: any }) => {+ filteredParamArr.forEach((_param) => {rawParams = {...rawParams,[_param.key]: _param.value,@@ -261,7 +251,7 @@ export default defineComponent({})},},-})+}</script><style scoped lang="scss">diff --git a/components/http/ImportCurl.vue b/components/http/ImportCurl.vueindex 701880ff4..aafb83183 100644--- a/components/http/ImportCurl.vue+++ b/components/http/ImportCurl.vue@@ -108,6 +108,11 @@ export default defineComponent({headers,preRequestScript: "",testScript: "",+ body: {+ contentType: "application/json",+ body: "",+ isRaw: false,+ },}))} catch (error) {diff --git a/components/http/Tests.vue b/components/http/Tests.vueindex 71bc7ff34..833bab91f 100644--- a/components/http/Tests.vue+++ b/components/http/Tests.vue@@ -93,16 +93,16 @@ export default defineComponent({}},computed: {- totalTests() {- return this.testResults.expectResults.length+ totalTests(): number | undefined {+ return this.testResults?.expectResults.length},- failedTests() {- return this.testResults.expectResults.filter(+ failedTests(): number | undefined {+ return this.testResults?.expectResults.filter((result: { status: string }) => result.status === "fail").length},- passedTests() {- return this.testResults.expectResults.filter(+ passedTests(): number | undefined {+ return this.testResults?.expectResults.filter((result: { status: string }) => result.status === "pass").length},diff --git a/helpers/utils/composables.ts b/helpers/utils/composables.tsindex 5726c779c..651514176 100644--- a/helpers/utils/composables.ts+++ b/helpers/utils/composables.ts@@ -1,5 +1,6 @@import {customRef,+ DeepReadonly,onBeforeUnmount,readonly,Ref,@@ -8,7 +9,10 @@ import {} from "@nuxtjs/composition-api"import { Observable, Subscription } from "rxjs"-export function useReadonlyStream<T>(stream$: Observable<T>, initialValue: T) {+export function useReadonlyStream<T>(+ stream$: Observable<T>,+ initialValue: T+): Ref<DeepReadonly<T>> {let sub: Subscription | null = nullonBeforeUnmount(() => {diff --git a/layouts/default.vue b/layouts/default.vueindex 3daa8117c..b208dbddc 100644--- a/layouts/default.vue+++ b/layouts/default.vue@@ -71,7 +71,7 @@ export default defineComponent({})this.$subscribeTo(getSettingSubject("BG_COLOR"), (color) => {- this.$colorMode.preference = color+ ;(this as any).$colorMode.preference = color})},async mounted() {@@ -85,7 +85,7 @@ export default defineComponent({"background-color:black;padding:4px 8px;border-radius:8px;font-size:16px;color:white;")- const workbox = await window.$workbox+ const workbox = await (window as any).$workboxif (workbox) {workbox.addEventListener("installed", (event: any) => {if (event.isUpdate) {