I encountered an eslint error when I was trying to configure Vue 3 + Quasar with a Firebase config.ts file. The error stated that there was an unsafe assignment of an `

Recently, I set up a new Vue 3 project with Quasar using the Quasar CLI.

In order to store my firebase configuration, I created a new file called src/firebase/config.ts, which looks like this:

// Import necessary functions from SDKs
import { initializeApp } from 'firebase/app';
import { getFirestore, serverTimestamp } from 'firebase/firestore';
import { getAuth } from 'firebase/auth';
import { getStorage } from 'firebase/storage';

// Firebase configuration
const firebaseConfig = {
  apiKey: 'REDACTED',
  authDomain: 'REDACTED',
  projectId: 'REDACTED',
  storageBucket: 'REDACTED',
  messagingSenderId: 'REDACTED',
  appId: 'REDACTED',
  measurementId: 'REDACTED',
};

// Initialize Firebase
const firebaseApp = initializeApp(firebaseConfig);

//Export modules
export const db = getFirestore(firebaseApp);
export const store = getStorage(firebaseApp);
export const auth = getAuth(firebaseApp);
export const timestamp = serverTimestamp();

The line

const firebaseApp = initializeApp(firebaseConfig);
is causing an eslint error -
Unsafe assignment of an 'any' value. eslint@typescript-eslint/no-unsafe-assignment
.

Here is the .eslintrc.js file generated by Quasar CLI during project setup:

(ESLint configuration file content)

I'm unsure why this error is occurring only with projects created using the Quasar CLI and not with the Vue CLI.

It seems that the difference in the configurations chosen by Quasar CLI and Vue CLI might be causing this issue.

Would merging certain parts from the Vue CLI's .eslintrc.js file into the one generated by Quasar CLI help resolve these errors?

(Vue CLI ESLint configuration file content)

Answer №1

Maybe give this a try - specify the type for your configuration:

const myFirebaseConfig: FirebaseOptions = ...

Then, define the firebase app using the specified type:

const myFirebaseApp: FirebaseApp = initializeApp(myFirebaseConfig);

Lastly, make sure to import these types:

import { FirebaseOptions, FirebaseApp, initializeApp } from "firebase/app";

Answer №2

It may seem silly, but simply giving my IDE (Visual Studio Code) a restart solved the issue and cleared all errors.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The initial click may not gather all the information, but the subsequent click will capture all necessary data

Issue with button logging on second click instead of first, skipping object iteration function. I attempted using promises and async await on functions to solve this issue, but without success. // Button Code const btn = document.querySelector("button") ...

Incorporate style elements dynamically using an array in Vue

My progress bar's width and color are determined by data from an array. The color of the bar changes based on the value of the data - grey if the progress is 0, blue if it's more than 0, and green if it's 100. <div class="card-item" v-fo ...

Utilize Typescript to inject types into a library

I have a code snippet that reads data from a JSON file and creates a type based on it, which is then used for further operations. import jsonData from './mydata.json' type CustomType = typeof jsonData .... This process ensures that the generate ...

What is the best way to invoke a function only once in typescript?

Struggling to implement TypeScript in React Native for fetching an API on screen load? I've been facing a tough time with it, especially when trying to call the function only once without using timeouts. Here's my current approach, but it's ...

Vue.js Interval Functionality Malfunctioning

I'm brand new to Vuejs and I'm attempting to set an interval for a function, but unfortunately it's not working as expected. Instead, I am encountering the following error: Uncaught TypeError: Cannot read property 'unshift' of u ...

billboard.js: The 'axis.x.type' property is conflicting with different data types in this context

axis: { x: { type: "category" } }, An issue has arisen: The different types of 'axis.x.type' are not compatible with each other. The value of 'string' cannot be assigned to '"category" | &qu ...

Developing Services in Vue similar to Angular

I created an API service for handling one of my resources, here is the code snippet: import axios from 'axios'; export default { get() { axios.get('/emails') .then((response) => { return respo ...

Having trouble integrating vue-phone-number-input into my VueJS Ionic project

I'm currently integrating vue-phone-number-input into my project. I successfully installed the package using npm install vue-phone-number-input. This is what my main.js looks like : // Code .... import VuePhoneNumberInput from 'vue-phone-number- ...

Angular Error: Trying to access a property on an undefined variable

I'm currently having an issue with assigning data from an API to my Angular component file. Whenever I try to assign the data to my object variable, I receive an error stating: "cannot set property of undefined." Below is the relevant code snippet: C ...

The VueJS nested data structure

As a newcomer to VueJS, I am exploring how to nest or reference component properties within others to ensure that the v-model binding updates them correctly. An example of what I'm trying to achieve is illustrated below. Template: <table> ...

Angular 11 along with RxJS does not support the combineLatest method in the specified type

Hey there, I'm currently working on utilizing the combineLatest operator to merge two streams in Angular, but I keep encountering an error message stating that "combineLatest does not exist on type". I've attempted to move the code into a .pipe() ...

How can you define the types of function arguments when destructuring arguments in TypeScript?

TS throws an error that states: Error:(8, 20) TS7031: Binding element 'on' implicitly has an 'any' type. Error:(8, 24) TS7031: Binding element 'children' implicitly has an 'any' type. Below is the function I am wor ...

Tips for concealing backend data in Angular2 under the conditions where the name is designated as anonymous and the nested array is empty

I'm dealing with an array of data fetched from the backend and I need to meet the following requirements: If the user's name, "from_user_name", is Anonymus, then the contents must be hidden. Hide the messages if the array is empty. Can someone ...

What could be causing the issue when attempting to run "npm run serve"?

Can anyone help me understand this error message and suggest a possible solution? Failed to compile. ./src/main.js Module build failed (from ./node_modules/eslint-loader/index.js): Error: No ESLint configuration found. at Config.getLocalConfigHierar ...

Guide on accessing a modal component in Angular?

I have an Edit Button on my component called SearchComponent. When the user clicks this button, it currently redirects them to another component named EditFormComponent using navigateByUrl('url-link'). However, I would like to enhance the user ex ...

Determining the Clicked Button in ReactJS

I need help with a simple coding requirement that involves detecting which button is clicked. Below is the code snippet: import React, { useState } from 'react' const App = () => { const data = [ ['Hotel 1A', ['A']], ...

Vue.js not responding to "mousedown.left" event listener

I am trying to assign different functionalities to right and left click on my custom element. Within the original code, I have set up event listeners for mouse clicks in the element file: container.addEventListener("mousedown", startDrag); conta ...

Tips for displaying the updated value retrieved from an array

I'm struggling with displaying the values of an object. The table is supposed to show tasks and their remaining time to finish, but the countdown timer isn't updating. The values are stored in an Object by Task ID, like this: Object {1: "4017 D ...

vuex: The decision between using $store.commit and directly calling the function

Recently, I discovered an interesting technique where store mutation functions can be passed into HTML events. Here's an example: //In the template <input name="the_field" :value="the_field" @input="updateField"/> // In the component methods ...

I am unable to view the Vuex state in components nested within v-tabs until the initial visit

Using the following dependencies: vuetify: ^2.5.10 vuex: ^3.6.2 vue: ^2.6.14 I have a project that utilizes v-tabs with a child component embedded in the first tab. Within this component, I have implemented a file input field and a button to ...